liveBook · Manning

Surrogate key

A surrogate key is an artificially assigned, domain-independent identifier used to uniquely identify a database record independently of its business attributes.

How 3 Manning books explain it

Grokking Relational Database Design

A surrogate key is an artificially created key value used to uniquely identify a row independently of the row's natural attributes.

How it is used
Identifies rows when no stable natural attribute can serve as a primary key.
How deep it goes
Explains auto-incrementing numeric IDs and their duplication limitation, then applies unique constraints to customer and dealer design.
Examples
Uses review_id for reviews and customer_id for customers whose email addresses and phone numbers can change.
What you can do after
Apply it by choosing an auto-incrementing ID for row identity and adding unique constraints where duplicate natural data is unacceptable.

Read how Grokking Relational Database Design explains surrogate key →

Java Persistence with Spring Data and Hibernate epub

A surrogate key is an application-meaningless primary key whose purpose is to identify stored data internally.

How it is used
Uses internal identifiers to decouple database identity from mutable or absent business keys.
How deep it goes
Explains rationale, foreign-key consequences, schema tradeoffs, and generation configuration, but defers Java-domain representation and generation strategies.
Examples
Uses USERS and BILLINGDETAILS tables with generated ID columns and a USER_ID foreign key.
What you can do after
Evaluate primary-key choices and configure generated identifiers when designing persistent tables and ORM mappings.

Read how Java Persistence with Spring Data and Hibernate epub explains surrogate key →

DuckDB in Action

A surrogate primary key is an artificially assigned identifier used as the primary key of a table instead of being derived from business data.

How it is used
Uses artificial identifiers to address rows when business attributes are not reliably unique.
How deep it goes
Defines surrogate keys and demonstrates sequence-backed creation, while contrasting them with externally generated and composite keys.
Examples
Demonstrates an externally generated system ID and a sequence-backed price ID in an energy-consumption schema.
What you can do after
Build it from scratch with SQL sequences, primary-key declarations, and separate business-uniqueness constraints.

Read how DuckDB in Action explains surrogate key →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.