Primary Key

Context: FIT2094_MOC · the chosen candidate key identifying a relation · selected by desirable-key criteria · natural vs surrogate

Quick Revision

  • 🎯 Objective: the one candidate key chosen as the relation’s identifier ➔ underlined in schema notation.
  • 📦 Core Components: desirable-key criteria ➔ natural vs surrogate PK.
  • ⚡ Key Constraint: carry the natural key through the whole design; add a surrogate only at the last step.

📝 Core

1. The Primary Key

  • Definition ➔ the one candidate key chosen as identifier; the rest become alternate keys.
  • Notation ➔ underlined, e.g. .

2. Desirable Characteristics

  • Unique + non-NULLentity integrity.
  • Non-intelligent + stable ➔ no embedded meaning, no change over time.
  • Preferably single-attribute + numeric ➔ simple FKs, auto-increment.
  • Security-compliant ➔ never a sensitive value (no TFN/SSN).

3. Natural vs Surrogate

  • Natural ➔ from the scenario (super→candidate→PK), captures business rules.
  • Surrogate ➔ artificial meaningless id (enrolment_id), added by the designer.

Key identities:

⚖️ Core Decision Matrix

CriterionGood PKBad PK (name)
uniqueyesno (shared names)
non-intelligentyesno (meaningful)
stableyesno (changes on marriage)
single/numericyesno

When It Flips: composite natural keys are valid but bloat FKs in children — the motivation for a single numeric surrogate. The PK functionally determines all attributes (Functional Dependency); it must reflect future data, not just current rows.

📊 Exam Execution Trace

Manual Execution Trace

Testing name as PK:

Step / StateCriterionName passes?
0 (Init)
1uniqueno
2stableno (marriage)
3non-intelligentno

⚠️ Common Mistakes

  • 💡 Carry the natural key through the design ➔ it encodes the business rules; a surrogate is added only at the final step (and is banned at the conceptual stage).

🧠 Active Recall