This Is Where Students Break
Candidate, Surrogate, Foreign.
The three keys to database sanity.
All possible IDs
The chosen one
The promise
Click each to test: "Will this still work 10 years later?"
Only one survives. The others become regular columns with UNIQUE constraints.
Natural keys change. Surrogate keys don't.
Has meaning in the real world
Invented by the database
"Databases prefer meaningless numbers.
Humans prefer meaning."
Not syntax. Meaning. A relationship enforced by the database itself.
"This value must exist somewhere else"
Click to reveal what happens when promises are broken.
Is this data or fiction?
Without FK constraints: It's "valid" data.
With FK constraints: IMPOSSIBLE to insert.
Click the ghost enrollment to see the truth.
All possible identifiers. We choose one to be Primary.
The chosen Primary Key. Meaningless, immutable, system-generated.
A promise that data exists elsewhere. Prevents orphans.
"Master these three keys, and you master relational thinking."