Skip to main content
PreparationZone Logo
PreparationZone
Back to Fundamentals

Fundamentals · Easy · Free

What is a primary key? Natural vs surrogate keys.

FresherFundamentalsDatabase Fundamentals
Model answer

Primary keys

Primary key uniquely identifies a row. Natural key uses business meaning (email); surrogate uses generated ID (UUID, auto-increment)—stable when natural keys change.

sql
id BIGSERIAL PRIMARY KEY  -- surrogate
UNIQUE (email)              -- business uniqueness
Prefer surrogate PK + unique on natural identifier.