Relationship design for areas, managers and general manager
-
13-03-2021 - |
Frage
Given some specifications I need to design a database for an organization. One of the parts has to do with areas. In the organization there are different areas, each area has a boss, and there is also an employee as the boss of all areas. My question is about how I should indicate which employee is the boss of all areas.
| employee_id | name |
| 1 | Mark |
| 2 | Carol |
| 3 | Adam |
| 4 | Andy |
| area_id | area_name | manager |
| 1 | Chemistry | 2 |
| 2 | Electronics | 4 |
| 3 | Medicine | 3 |
| 4 | ALL | 1 |
At the moment what has occurred to me is to create an occurrence called "ALL" within the relation "AREA" to indicate the head of all areas, however I am not sure if it is the best way or the correct way to do it . Any other idea?
Lösung
It's ok to have an "ALL" value as an Area
but it might be preferable and more flexible to add a third table, as a linking table, called EmployeeArea
instead.
The EmployeeArea
table is where you can store the area_id
and employee_id
(as manager_id
), to represent the technically many-to-many relationship between the tables. Then the boss of all areas would have a record in there for each Area
.
This is more normalized of a design, and is more flexible if for some reason there needs to be multiple bosses of all areas, or special cases where multiple employees are responsible for the same area.