Many to Many [recursive]
Diagram M2M-rec.png
How to read One employee may manage many employees. Each employee may be managed by many managers.
Relevant relations Both many sides of this relation can be either optional or mandatory.

The table structures are as follows:

employee(__id__, name, <e_other>)
manage(__emp_id*, mgr_id*__)

The SQL create statement is as follows:

create table employee
  (id type primary key,
   name type,
   <e_other>);
create table manage
  (emp_id type,
   mgr_id type,
   primary key (emp_id, mgr_id),
   foreign key (mgr_id) references employee,
   foreign key (emp_id) references employee);

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