One (optional) to One (optional) [recursive]
|How to read||One employee may manage one other employee, and each employee may be managed by one employee.|
The table structures are as follows:
employee(__id__, name, <e_other>) manage(__mgr_id__*, emp_id*)
The SQL create statements are as follows:
create table employee (id type primary key, name type, <e_other>); create table manage (mgr_id type primary key, emp_id type not null unique, foreign key (mgr_id) references employee, foreign key (emp_id) references employee);
The reader should note that either mgr_id or emp_id could be the primary key of manage.
Back to ER to SQL page.
page revision: 2, last edited: 21 Aug 2008 00:32