SQL · Queries that survive scale
What is database normalization and why does it matter?
Short answer
Normalization organizes data to remove redundancy and update anomalies. It usually means separating entities into tables and relating them with keys, following forms such as 1NF, 2NF, and 3NF.
The normal forms are rules about dependencies. First normal form removes repeating groups and requires atomic values. Second normal form removes partial dependencies on part of a composite key. Third normal form removes transitive dependencies between non-key columns.
CREATE TABLE customers (
id BIGINT PRIMARY KEY,
email TEXT NOT NULL UNIQUE
);
CREATE TABLE orders (
id BIGINT PRIMARY KEY,
customer_id BIGINT NOT NULL REFERENCES customers(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);What normalization buys you
- One authoritative place for each fact, so updates do not diverge
- Smaller rows and fewer contradictory copies
- Constraints can express real business rules
- Queries can combine entities through joins without duplicated state
- Schema changes are easier when data is not copied across many columns
Normalization is a default, not a religion. Highly normalized schemas can require many joins for read-heavy reporting. The usual approach is to normalize transactional data and denormalize selectively in read models or materialized views.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What problem does third normal form solve?
- 2When would you deliberately violate normalization?
- 3How do you handle many-to-many relationships?
- 4What is an update anomaly?
Say it in the interview
Normalization removes redundancy by giving each fact one home and relating tables through keys. That prevents update anomalies, where the same value is changed in one place but not another. I normally normalize transactional data to at least third normal form. For read-heavy paths I denormalize deliberately, with a clear owner and a process for keeping the copy consistent.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live SQL mock interview and get scored feedback on depth, clarity and confidence.