liveBook · Manning

Database normalization

As explained in Crack Any Codebase with AI

Database normalization is the practice of organizing data so that each fact is stored in one appropriate place and related records reference it.

Database normalization puts each fact in one appropriate place and lets related records reference it. It reduces update anomalies, but reads may require more joins. section 7.4

Use the schema to ask where each fact lives and why exceptions exist:

  • Give repeating relationships their own tables: Booking connects to Attendee rather than storing multiple guests in one crowded column. section 7.4
  • Recognize denormalization as a deliberate read optimization: a flattened routing-form copy avoids repeated JSON parsing and joins. section 7.4
  • Treat synchronization mechanisms as part of the design: a PostgreSQL trigger keeps the flattened copy current, but can drift if defective. section 7.4
Table 7.3 A mostly normalized schema, with one denormalized table to speed up a high-volume analytics query.
Posture
Where in Cal.com
What it buys
What it costs
Normalized (one fact, one place)
Booking → Attendee, Booking → Payment, User → Schedule
No update anomalies; a fact changes in exactly one row
Every read pays for joins, and a wide read touches many tables
Read-denormalized (copy, kept fresh by trigger)
RoutingFormResponseDenormalized, RoutingFormResponseField
Analytics and filter queries skip the JSON parse and the joins
A trigger you have to trust; the copy can drift if the trigger has a bug
JSON escape hatch (no shape at all)
Booking.responses, Booking.metadata, EventType.locations
Ship a new field with zero migration
Unqueryable without a GIN index; the schema stops describing the data

Compare normalized tables, read-denormalized copies, and JSON escape hatches by their benefits and operational costs. section 7.4

How Crack Any Codebase with AI covers it

How deep it goes
Defines one-fact-one-place design and explains normalized, denormalized, and JSON alternatives, without formal normal-form analysis.
Examples
Uses Booking–Attendee relationships and flattened routing-form data maintained by a PostgreSQL trigger.
What you can do after
Evaluate schema choices by identifying update-anomaly risks, join costs, read optimizations, and synchronization liabilities.
How it connects
Connects normalization to denormalization, database joins, JSON data, analytics queries, and database triggers.

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 Crack Any Codebase with AI. The section links point to the parts of the book it draws on.