Arman Pouyaei Start a conversation
Lesson 12  ·  Oct 19, 2026
Data Engineering Fundamentals

Stop storing the same fact twice: normalization

Database management, lesson four. Schemas organized tables, keys protected relationships, indexes made them fast. Today’s idea sits underneath all of them: normalization — the design discipline of splitting tables so every fact is stored in exactly one place.

The code

-- Smelly design: region_name repeats on EVERY station row,
-- and it depends on region_id, not on station_id
CREATE TABLE weather_stations (
    station_id   INT PRIMARY KEY,
    name         VARCHAR(50),
    region_id    INT,
    region_name  VARCHAR(50)
);

The problem is an update anomaly: rename a region and you must rewrite every station row — miss one and your data lies to every query that reads it. The fix is to store each fact once:

CREATE TABLE regions (
    region_id   INT PRIMARY KEY,
    region_name VARCHAR(50)
);

CREATE TABLE weather_stations (
    station_id  INT PRIMARY KEY,
    name        VARCHAR(50),
    region_id   INT REFERENCES regions(region_id)
);

Now a region’s name lives in exactly one row. A rename is one UPDATE, and the FOREIGN KEY (lesson 10) still guarantees every station points at a real region. Getting the name back is one JOIN — the trade you accept for clean data.

In practice

Normalization has textbook stages: 1NF — one value per cell, no lists or repeating groups; 2NF — every column depends on the whole primary key; 3NF — no column depends on a non-key column (our region_name depended on region_id, not station_id — a 3NF violation). Transactional databases aim for 3NF, and a data engineer’s schema-design skill is mostly this: spotting which column belongs to which table.

But here’s the twist that meets your world: data engineers often deliberately denormalize in the warehouse. Wide fact tables and star schemas repeat dimensions because one fat row is cheaper to scan than a 5-way JOIN over billions of rows. Normalization is the starting discipline; denormalization is a conscious performance tradeoff — never an accident.

Python bridge: normalization is the DRY principle for data. Don’t paste the same constant into 50 functions — put it in one config dict and import it. Same idea: one row of truth, referenced everywhere, so a change happens in exactly one place.

Further reading

Database Normalization – Normal Forms 1NF 2NF 3NF Table Examples — freeCodeCamp (short walkthrough of 1NF to 3NF with before/after table examples, including the SQL to build each version)

Try it

Practice question: your pipeline lands a table storm_readings with columns reading_id, station_id, station_name, lat, lon, value_c, reading_time. Every reading repeats the station’s name, latitude, and longitude. What’s wrong with this design, and how would you split it into two clean tables?

Show answer

The station facts (station_name, lat, lon) depend on station_id, not on reading_id — a 3NF violation with a nasty update anomaly (rename a station or correct its coordinates, and thousands of reading rows are stale). Split it:

CREATE TABLE stations (
    station_id   INT PRIMARY KEY,
    station_name VARCHAR(50),
    lat          DECIMAL(9, 6),
    lon          DECIMAL(9, 6)
);

CREATE TABLE storm_readings (
    reading_id   INT PRIMARY KEY,
    station_id   INT REFERENCES stations(station_id),
    value_c      DECIMAL(6, 2),
    reading_time TIMESTAMP
);

Result: station facts live in exactly one row each; readings hold only the foreign key. Rename a station once, and every downstream join sees it. Notice the design pattern repeating: spot the fact, find the table it belongs to, link with a key.

← All posts