liveBook · Manning

Denormalization

As explained in Crack Any Codebase with AI

Denormalization is the deliberate duplication or flattening of data to reduce query work and improve read performance.

Denormalized data deliberately duplicates or flattens related facts so frequent reads avoid repeated joins, JSON parsing, or wide multi-table queries. It trades one authoritative copy for faster, simpler read paths. section 7.4

A read-optimized analytics table

Cal.com is mostly normalized: bookings, form responses, and fields live in separate tables. RoutingFormResponseDenormalized flattens their joined data into one wide table. A Postgres trigger keeps the copy fresh, allowing the analytics dashboard to filter without rejoining tables or parsing JSON on every page load. The cost is trigger maintenance and possible drift when synchronization fails. section 7.4

Figure 7.5 The Cal.com schema is mostly normalized, joining tables like booking, form_response, and form_field. The routing_form_denormalized table is the exception: a wide, flat copy of the joined data, kept fresh by a Postgres trigger. This lets the analytics dashboard query a single table instead of re-joining the originals and parsing JSON on every page load.

Use the schema figure to compare normalized joins with the wide, trigger-maintained denormalized table and see which read work it removes. section 7.4

How Crack Any Codebase with AI covers it

How deep it goes
Explains the read benefit, synchronization mechanism, and drift risk, but stops short of trigger implementation details.
Examples
Uses Cal.com's RoutingFormResponseDenormalized table and its trigger-maintained copy of joined routing-form data.
What it assumes
Assumes familiarity with tables, joins, JSON fields, and database triggers.
What you can do after
Evaluate read-performance designs by weighing skipped joins against synchronization failures and stale duplicated data.
How it connects
Connects database normalization, database triggers, joins, JSON data, and analytics queries.

Also explained in

Compare how 8 books explain denormalization →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Crack Any Codebase with AI. The section links point to the parts of the book it draws on.