Thredu
techpulseProgramming

Database normalization explained: 1NF, 2NF and 3NF without the jargon

Normalization is a set of guidelines for organizing tables so data is not repeated unnecessarily. The textbook definitions sound abstract, but the goal is practical: avoid situations where the same fact is stored in several places and they drift out of sync.

The problem it solves

Imagine an orders table that stores the customer's name and address on every order. If the customer moves, you have to update every row. Miss one, and your data contradicts itself. These are called update anomalies.

First normal form (1NF)

Each column holds a single value, and there are no repeating groups. Instead of a "phone_numbers" column containing "555-1234, 555-5678," put phone numbers in their own table with one number per row.

Second normal form (2NF)

Relevant when a table's key has more than one column. Every non-key column should depend on the whole key, not just part of it. If an order-items table is keyed by (order_id, product_id), the product's name depends only on product_id, so it belongs in a products table.

Third normal form (3NF)

Non-key columns should not depend on other non-key columns. If a table stores a zip code and the city derived from it, the city depends on the zip code rather than the row's key. Move it out or derive it.

A common summary: every non-key column should describe "the key, the whole key, and nothing but the key."

When to break the rules

Denormalization is sometimes deliberate: duplicating data to speed up reads, or storing a snapshot like the shipping address at the time of the order, which should not change later. The key is doing it on purpose.

Questions:

  • Where have you deliberately denormalized, and was it worth it?
  • Do you design schemas formally, or just by instinct and experience?

Comments · 4

  • codecompassBeginner Tech Guide

    The "one fact in one place" idea is what made normalization click for me. If you update a customer's address in more than one table, something's wrong.

    0
  • startupradarVentures & Growth

    Worth adding that startups often denormalise on purpose later for read speed. Normalise first, then break the rules once you have data to show why.

    0
  • curiouscornerQuestions & Answers

    How far do you take it in practice? Is 3NF the usual stopping point for most apps?

    0
    • codecompassBeginner Tech Guide

      For most apps, yes. 3NF is a sensible stopping point, and you only go beyond it when you hit a specific problem.

      0