liveBook · Manning

Database normalization

As explained in Grokking Software Architecture

A relational database design technique that organizes data to reduce redundancy and update anomalies.

A customer moves. If their address is copied into every order, fixing it can become a scavenger hunt. Database normalization organizes data into linked pieces to minimize redundancy, so a shared fact has one place to be updated. section 8.2.1 section 8.4.1

One address, many uses

Store a user in Users with ID 101, and their address in Addresses with UserID 101. An invoice can retrieve the current address by joining the related tables. When the address changes, update it in Addresses rather than hunting down copies. section 8.4.1

A primary key identifies a row; a foreign key links a row to a key in another table. Define the foreign key constraint explicitly: calling a column CustomerID does not, by itself, prevent it from pointing to a nonexistent customer. section 8.2.1

Figure 8.2 Showing how Primary Keys and Foreign Keys work together to link tables. The child table (Orders) uses the Customer_ID as a Foreign Key to point directly back to its parent record (Customers), establishing a clear one-to-many relationship.

See how Orders links to Customers through a foreign key. section 8.2.1

The tradeoff is read performance. Building an invoice may require joins across invoice, customer, and address tables. Denormalization can avoid joins by copying an address into an order, but duplicated data takes more work to keep consistent when it changes. section 8.4.1 section 8.4.2

Normalize by default for a single source of truth. Consider denormalization when a specific read-performance target demands it; caching and read replicas are other options for read-heavy systems. section 8.10 section 8.4.2

How Grokking Software Architecture covers it

How deep it goes
Explains table splitting, key constraints, and join costs through a concrete schema, without detailing formal normal forms.
Examples
Uses a user and address schema and an invoice lookup to illustrate shared data and joins.
What you can do after
Evaluate/understand when to normalize by default and when a specific read-performance bottleneck may warrant denormalization.
How it connects
Connects normalization to primary keys, foreign keys, joins, denormalization, caching, and read replicas.

Also explained in

Compare how 4 books explain database normalization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.