Search code examples
databasedatabase-designrdbmserd

Drawing ERD for this Sample Database


Consider a system where employee record is kept. The database should store employee name,department etc. Every employee has a reporting manager to whom he has to report. There are 4 levels of employee –

  1. Junior Engineer
  2. Senior Engineer
  3. Team Lead
  4. Senior Team Lead

Every junior engineer has to report to Senior engineer. Every senior Developer has to report to team lead. Every team lead has to report to senior team lead.

I came to this idea:-

There will be two table

1.Employee

2.Reporting

Employee table would contain necessary information like EmployeeID,Employee Name,Department Name etc.; primary key is EmployeeID

Reporting Table would contain two columns EmployeeID and ReportingMangerID ;EmployeeID is foreign key related to Primarykey of Employee Table.

I dont know if I am correct.


Solution

  • If the following is true:

    • one employee reports to 0..1 other employees
    • one employee has 0..n reports

    Then you can have "manager" as an attribute for the employee table.

    If the following is true:

    • one employee reports to 0..n other employees
    • one employee has 0..n reports

    Then you need to have your structure.