Search code examples
sqldatabasedatabase-designerd

Database ERD loop query


Hi I have the following database design problem I need to resolve.

A section employs many staff members

Each section has multiple phone numbers

Each staff member has their own internal telephone number.

I have created three entities: Phone, Staff and Section. The phone entity store the numbers with the phone number as the PK. However, the ERD I have created has a loop between the three entities. Any simple solutions to avoid the loop using the phone entity?

Phone Loop ERD Image


Solution

  • My understanding of an ERD loop is different from yours. In my understanding, an ERD loop is when the foreign key references go around and around endlessly. In your case, there would be a loop if Section had an FK reference to staff. Then section references staff, staff references phone, and phone references section, in a loop.

    You haven't modeled it that way, because that would be incorrect in your case. You have correctly modeled it the other way, with Staff referencing Section.

    So you don't really have a loop. Staff references both phone and section, but those are independent relationships.

    So why is it still a problem?