Mapping Binary Relationships (Logical)

Context: FIT2094_MOC · map 1:M, M:N, 1:1 relationships to foreign keys · M:N needs a bridging relation · 1:1 minimises NULLs

Quick Revision

  • 🎯 Objective: map a binary relationship by FKs, rule set by cardinality ➔ 1:M / M:N / 1:1.
  • 📦 Core Components: 1:M (FK on many) ➔ M:N (bridge relation) ➔ 1:1 (FK to minimise NULLs).
  • ⚡ Key Constraint: M:N needs a bridging relation; 1:1 total → consolidate.

📝 Core

1. 1:M

  • Rule ➔ the one side’s PK becomes an FK on the many side.
  • Direction determined ➔ the one-side PK can appear many times there.

2. M:N

  • Bridge relation ➔ both parents’ PKs as FKs, usually forming a composite PK.
  • Two 1:M ➔ one per FK; plus relationship attributes.
  • Own identifier ➔ if the bridge has its own key, the FKs need not form the PK.

3. 1:1

  • FK on mandatory side ➔ minimise NULLs, enforce “must participate”.
  • Total both sides ➔ consolidate into one relation.

Key identities:

When It Flips: the two M:N FKs usually form the PK, but a supplied surrogate/own identifier (Associative Entity) makes them non-key FKs. Placing a 1:1 FK on the mandatory side both minimises NULLs and enforces the "must participate" rule.

📊 Exam Execution Trace

Manual Execution Trace

Choosing FK placement:

Step / StateRelationshipRule
0 (Init)
1CUSTOMER 1:M ORDERcust_id FK in ORDER
2ORDER M:N PRODUCTORDERLINE bridge
3NURSE 1:1 CARECENTERnurse_id FK in CARECENTER

⚠️ Common Mistakes

  • 💡 1:M FK direction is determined, not chosen ➔ the FK must go on the many side; reversing it would need a multivalued attribute.

🧠 Active Recall