concept

Surrogate Key

also called Synthetic Key

A system-generated identifier with no business meaning, used as the primary key instead of a naturally occurring business value.

modellingkeysidentifiers

A natural key — an email address, a national insurance number, an ISBN, a country code — is meaningful and therefore changes. People change email addresses, standards get revised, countries split. When the key changes, every foreign key referencing it must change too.

A surrogate key never changes because it means nothing. Business values become ordinary attributes, with a unique constraint where uniqueness is genuinely required.

The choice of surrogate matters more than it looks. Auto-increment integers are compact and index-friendly, and they leak volume (/orders/1042 tells a competitor how many orders you have) and do not work across shards. UUIDv4 is globally unique and randomly distributed, which destroys index locality and causes page splits on a B-tree. Time-ordered identifiers — ULID, UUIDv7, Snowflake IDs — are the usual modern answer: globally unique, sortable, and index-friendly because they are roughly sequential.

And the Pinterest pattern is worth remembering: a surrogate key can encode its own shard, which removes the need for a lookup service entirely.