One (optional) to One (optional) [recursive]
Diagram 1o21o-rec.png
How to read One employee may manage one other employee, and each employee may be managed by one employee.
Relevant relations None.

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.

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