The row's permanent identity
A primary key is a row's permanent name — unique across the table, never null, ideally never changing. Without one, you cannot reliably point at a row from another table, from your application, or from a future you debugging at 2am. Every table should have one. No exceptions.
What makes a good primary key
- Unique. No two rows share the value.
- Not null. Every row has one.
- Immutable. The value never changes after the row is created.
- Compact and indexable. Integer or UUID — not a 200-character composite of business fields.
Surrogate vs natural keys
A natural key uses real-world data (email, ISBN, phone). A surrogate key is a system-generated value with no business meaning (auto-increment integer, UUID). Prefer surrogate keys; keep natural fields like email as UNIQUE constraints. Real-world identifiers do change (people change emails, ISBNs get reissued), and changing a primary key cascades pain through every foreign-key reference.
Composite primary keys
For pure junction tables (many-to-many bridges), a composite key of the two foreign keys is the natural fit and saves you a redundant surrogate column.