One (optional) to One (mandatory) [recursive]
|How to read||One employee may manage one other employee, but each employee is managed by exactly one employee.|
The table structure is as follows:
employee(__id__, name, mgr_id*, <e_other>)
The SQL create statement is as follows:
create table employee (id type primary key, name type, mgr_id type not null, <e_other>, foreign key (mgr_id) references employee);
Since this relationship is optional in one direction, this is the only way this relationship should be represented in the database.
Back to ER to SQL page.
page revision: 1, last edited: 21 Aug 2008 00:30