Surrogate Key

Context: FIT2094_MOC · a system-generated artificial Primary Key · added only at the logical stage · the natural key kept via a unique constraint

Quick Revision

  • 🎯 Objective: a system-generated meaningless PK replacing a natural key ➔ simplifies composite keys.
  • 📦 Core Components: added only logically ➔ natural key kept via UNIQUE constraint.
  • ⚡ Key Constraint: without the UNIQUE constraint, the natural-key business rule is lost.

📝 Core

1. The Surrogate

  • Definition ➔ a system-generated, business-meaningless identifier used as Primary Key in place of a natural key.
  • Stageonly at logical design — never conceptual.

2. Why Add One

  • Composite keys are unwieldy ➔ an index per key attribute, more storage, slower, bloats child FKs.
  • Single numeric id ➔ one easy-to-manage identifier.

3. Protect the Natural Key

  • Manual add ➔ new PK attribute (et_no); don’t use a modeller’s auto option.
  • Former composite → attributes ➔ enforce UNIQUE (NOT NULL) on the natural key.

⚙️ Core Implementation

🔹 EMPLOYEE_TRAINING with surrogate

⚖️ Core Decision Matrix

AspectNatural PKSurrogate PK
meaningbusiness rulesnone
sizecompositesingle numeric
child FKsbloatedsimple
natural keyis the PKkept as UNIQUE

When It Flips: the natural key encodes the Normalisation rules, so it must be kept and enforced; the surrogate only replaces it as the PK, not the rule. Added at the end of logical design, after 3NF and ER mapping.

📊 Exam Execution Trace

Manual Execution Trace

Adding a surrogate:

Step / StateActionResult
0 (Init)composite natural PKunwieldy
1add et_no PKsingle numeric id
2natural key → attributesneeds protection
3UNIQUE(natural key)rule preserved

Applied Exercise

Problem: After adding surrogate et_no, how is the natural key protected and why? Derivation Proof / Hand-Calculation Walkthrough:

Final Extracted Output: a UNIQUE (NOT NULL) constraint on the natural key preserves the business rule.

🧠 Active Recall