Consider this case where I'm trying to model a database for a company:
- Entities:
Employees,Managers,Departments. - An
Employeeworks in only 1Departmentwhile aDepartmentmay have manyEmployeesworking in it. - A
Managermay manage only 1Departmentand similarly aDepartmentmay have only 1Manager. - A
Managersupervises manyEmployees, but anEmployeeis only supervised by oneManager.
Now I have 2 ways to model this:
First solution:
I'll consider that the Manager entity inherits from the Employee entity considering that I'll keep data that is unique to the Managers (e.g. Bonus & Status).

Since the relation between
DepartmentandEmployeeis1:Nthen I'll put theDepartment Idas a foreign key in theEmployeetable for theWorksrelation.Since the relation between
DepartmentandManageris1:1then I'll put theDepartment Idas a foreign key in theManagertable for theManagesrelation.
Problem: How can I represent the recursive relation between the Manager and Employee?
Second solution:
I'll consider that the Manager entity is not needed as other Employees may also have a Bonus and Status. (Actually I added these 2 attributes just to see how to model it in both cases)

- Since the relation between
DepartmentandEmployeeis1:Nthen I'll put theDepartment Idas a foreign key in theEmployeetable for theWorksrelation. - Since the relation between
EmployeeandManageris1:Nthen I'll put theEmployee Idas a foreign key in theEmployeetable for theSupervisesrelation and call itManager Id.
Problem: How can I represent the relation between the Manager and Department?
Questions:
- Is there any obvious mistakes in both design as they are?
- How to solve each problem in both cases?
- Is there a better solution than these two?



