One (mandatory) to One (mandatory) [recursive]
Diagram 1m21m-rec.png
How to read One employee must manage exactly one other employee. Each employee must be managed by exactly one other 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 unique,
   <e_other>,
   foreign key (mgr_id) references employee);

The table could also have the following structure:

employee(__id__, name, emp_id*, <e_other>)

The SQL create statement for this version is as follows:

create table employee
  (id type primary key,
   name type,
   emp_id type not null unique,
   <e_other>,
   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