简体   繁体   中英

ER Model: how to represent staff members vs staff work place possibilities? 2 relationships between 2 entities?

I am trying to define an ER Model, about staff members roles vs office place options. I have different roles to assign as possibilities at each office (limited options).

Each office must have a staff member as “Chief of Happiness Manager" role (one and only one), but it is possible to exist more roles at one office.

Every staff member can work for several offices but assume only one role at each office. Staff members can assume different roles in different offices.

How can I represent this is terms of ER Model? Does it make sense to have 2 relationships between 2 entities in ER diagram?

There are probably many ways to do this. So this is just one option.

Assuming you have 3 tables (entities)

  • Staff (Entity) with StaffID (Primary Key)

  • Office (Entity) with OfficeID (Primary Key)

  • Role (Entity) with RoleID (PrimaryKey)

You can model the relationship through a table OfficeRoleStaff which has 3 Foreign Keys OfficeID, RoleID and StaffID which in turn can form a unique Primary Key (Composite Key) and would act as a constraint (Primary Key Constraint ie must be unique) as each Staff can then only have one role-office combination. This seems to meet the outlined requirement.

The Chief Of Happiness can be part of this table or a separate table (Mandatory One relationship) but it would be entirely possible to set this up in the OfficeRoleStaff table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM