One (optional) to One (mandatory) [recursive]
Diagram 1o21m-rec.png
How to read One employee may manage one other employee, but each employee is managed by exactly one employee.
Relevant relations None.

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,
   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.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License