Software → Databases
Primary Key
A column or set of columns that uniquely identifies each row in a relational table.
Motivation
A primary key solves the problem of giving every row a stable identity.
Where it fits
It belongs to relational databases and data modeling.
Mental model
A primary key is the row identity other rows can point to and applications can use safely.
Important details
Good primary keys are unique, stable, and indexed. They may be natural or surrogate keys.
Common mistakes
- Using mutable business fields as primary keys without considering change.
- Confusing primary keys with display names.