Module P-4·24 min read

Normalisation, denormalisation trade-offs, correct data types for money and time, soft deletes, and schema migration tools.

JJS
Written by Jatin Jain Saraf · Senior Software Engineer

P-4 — Schema Design for Real Applications

Who this module is for: You can write SQL and use constraints. Now you need to design schemas that hold up under real conditions: changing requirements, growing data, and teams who make mistakes. This module covers the principles and decisions that distinguish schemas built to last from schemas that cause pain six months into production.


Normalisation in Plain English

Normalisation is the process of organising tables to reduce data redundancy and improve integrity. Academics describe it in terms of normal forms (1NF, 2NF, 3NF). In practice, you need one intuitive rule:

Each fact should be stored in exactly one place.

If the same piece of information is stored in multiple rows or multiple tables, changing it requires updating multiple places — and when someone forgets one, your data becomes inconsistent.

The redundancy problem

sql
sql

When to intentionally denormalise

Normalisation is the default. Denormalisation is a deliberate trade-off:

  • High read volume, low update frequency: a reporting table that aggregates data from many tables — it is faster to pre-compute and store than to join 8 tables on every read
  • Historical snapshots: an orders table should store the price at the time of purchase, not reference the current products.price — prices change, but the order price should not
  • Audit logs: copy the full state of a row when it changes — redundancy is intentional
sql

Choosing the Right Data Types

Money: NUMERIC, Not FLOAT

sql

Timestamps: TIMESTAMPTZ, Always

sql

Enumerations: TEXT with CHECK vs ENUM type

sql

Recommendation: use TEXT NOT NULL CHECK (... IN ...) for flexibility. Use ENUM only when you need the type enforced at the type system level or need ordering (e.g., priority levels).

Boolean Columns

sql

UUID vs BIGSERIAL

sql

Sign in to keep reading

The rest of this module is free — sign in with Google to unlock it and track your progress.

Sign in & Register

Discussion

0

Join the discussion

Loading comments...

© 2026 Jatin Jain Saraf (JJS). All rights reserved.