liveBook · Manning

Denormalization

As explained in Microsoft Azure in Action

Denormalization is the intentional introduction of redundant or combined data into a relational schema to improve read performance or simplify access.

Denormalization deliberately stores redundant or combined data so an application can retrieve what it needs with fewer joins or queries. It trades some storage efficiency and update simplicity for faster, simpler reads. section 10.2.1 section 11.3.1

Keep a comment count with each post

A blog can add a comment-count column to its Posts table. A list of posts can then show each count without joining Posts to Comments and counting the matching rows every time. The catch: when comments change, the stored count must stay accurate. section 10.2.1

Figure 10.2 Denormalizing the Posts table by adding the count of comments on each post

Shows the comment count stored on each post rather than calculated from the Comments table for every list view. section 10.2.1

The same idea applies to documents. In Azure Cosmos DB, related supplier details can sit inside a product document, allowing a complete product to be retrieved in one query instead of assembled through joins. Duplication still needs care: updates may have to reach multiple copies, and missed updates can leave inconsistent data. Choose where to denormalize based on the reads, writes, and maintenance your application actually needs—not because every join is a villain. section 11.3.1 section 10.2.1

How Microsoft Azure in Action covers it

How deep it goes
Defines the technique and works through examples and trade-offs, without providing an implementation procedure.
Examples
Illustrates a post’s stored comment count and supplier details embedded in a product document.
What it assumes
Builds on relational tables and joins, illustrating both through a customer-and-order example.
What you can do after
Evaluate/understand when fewer joins or queries justify redundant data and its storage and consistency costs.
How it connects
Connects normalization, database schemas, joins, data integrity, and schema-less data modeling.

Also explained in

Compare how 6 books explain denormalization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.