0Pricing
SQL Interview Prep · Lesson

Normalization Through 3NF

First, second, and third normal form with the anomalies they remove.

Normalization Through 3NF is a free SQL Interview Prep lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the SQL Interview Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Interviewers Ask About Normalization

Normalization is a database modeling fundamental, and interviewers use it to test whether you understand data integrity at the design level. The question often sounds like: "What is normalization and why does it matter?"

Normalization is the process of organizing columns and tables to reduce redundancy and prevent update, insert, and delete anomalies. Each normal form (1NF, 2NF, 3NF) adds a stricter rule.

A strong answer names the anomalies normalization removes, not just the textbook definitions.

The Three Anomalies

Before the normal forms, learn the problems they solve. A poorly designed table that stores everything in one place suffers three anomalies:

  • Update anomaly: the same fact is stored in many rows, so a change must touch all of them or data goes inconsistent.
  • Insert anomaly: you cannot add a fact without also supplying unrelated data (e.g. cannot add a product without an order).
  • Delete anomaly: deleting one row accidentally erases another independent fact.

If you can spot these in a sample table, you can justify every normalization step.

An Unnormalized Starting Table

Here is a classic interview example: one wide table mixing orders, customers, and products. Notice the repeated customer email and product price across rows. This is where the anomalies live.

Your job in the interview is to walk this table up to 3NF, explaining each split.

-- Unnormalized: everything in one table
CREATE TABLE orders_flat (
  order_id     INT,
  customer_id  INT,
  customer_email VARCHAR(255),
  product_id   INT,
  product_name VARCHAR(100),
  unit_price   DECIMAL(10,2),
  quantity     INT
);

First Normal Form (1NF)

1NF requires that every column hold a single atomic value and that there are no repeating groups or arrays inside a cell.

A table violates 1NF if a column stores a comma-separated list like 'phone1, phone2' or if you have columns product1, product2, product3.

The fix: give each value its own row. The interviewer wants to hear "atomic values, no repeating groups, and a key that identifies each row."

-- Violates 1NF: a list inside one column
-- phones = '555-1111, 555-2222'

-- 1NF fix: one phone per row
CREATE TABLE customer_phone (
  customer_id INT,
  phone       VARCHAR(20),
  PRIMARY KEY (customer_id, phone)
);

Functional Dependencies

To explain 2NF and 3NF you must use the term functional dependency. We write A -> B to mean "A determines B": for each value of A there is exactly one value of B.

In our orders table:

  • customer_id -> customer_email
  • product_id -> product_name, unit_price
  • order_id, product_id -> quantity

Normalization is really about making sure every non-key column depends on the whole key, and nothing but the key.

Second Normal Form (2NF)

2NF applies when the primary key is composite. It forbids a non-key column from depending on only part of the key (a partial dependency).

Our line-item key is (order_id, product_id). But product_name and unit_price depend only on product_id, not the full key. That is a partial dependency, so it violates 2NF.

The fix: move product attributes into a products table keyed by product_id.

CREATE TABLE products (
  product_id   INT PRIMARY KEY,
  product_name VARCHAR(100),
  unit_price   DECIMAL(10,2)
);

CREATE TABLE order_items (
  order_id   INT,
  product_id INT,
  quantity   INT,
  PRIMARY KEY (order_id, product_id),
  FOREIGN KEY (product_id) REFERENCES products(product_id)
);

Third Normal Form (3NF)

3NF removes transitive dependencies: a non-key column that depends on another non-key column rather than directly on the key.

Suppose an orders table has customer_id plus customer_email. Here order_id -> customer_id -> customer_email. The email depends on the key only through customer_id, a transitive dependency.

The fix: split customers into their own table. Now each table's non-key columns depend only on its key.

CREATE TABLE customers (
  customer_id    INT PRIMARY KEY,
  customer_email VARCHAR(255)
);

CREATE TABLE orders (
  order_id    INT PRIMARY KEY,
  customer_id INT,
  FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);

The One-Line Memory Aid

Interviewers love a candidate who can summarize 3NF in one sentence. The classic phrasing:

"Every non-key column must depend on the key, the whole key, and nothing but the key."

  • The key -> 1NF (there is a key, atomic values).
  • The whole key -> 2NF (no partial dependency).
  • Nothing but the key -> 3NF (no transitive dependency).

This single line lets you reconstruct all three forms on demand.

BCNF: The Follow-Up Question

A sharp interviewer may ask about Boyce-Codd Normal Form (BCNF), a stricter version of 3NF.

BCNF requires that for every functional dependency X -> Y, X must be a superkey. 3NF allows a rare exception when the dependent attribute is part of a candidate key; BCNF removes even that.

You will not see BCNF violations often in practice, but naming it and saying "BCNF is 3NF with no exceptions for prime attributes" signals depth.

When NOT to Normalize

A senior-level answer acknowledges the trade-off. Normalization improves integrity but can hurt read performance because answering a query needs more joins.

Deliberate denormalization is acceptable when:

  • The workload is read-heavy and joins are the bottleneck.
  • You are building an analytics/reporting layer (star schemas, covered later).
  • You can keep the redundant copy in sync (triggers, ETL, materialized views).

Say: "Normalize for OLTP integrity; denormalize deliberately for OLAP read speed."

Walking the Whiteboard

Put it together. In a live interview, given a messy table:

  • State the candidate key and list functional dependencies.
  • Check atomicity and repeating groups (1NF).
  • If the key is composite, check for partial dependencies (2NF).
  • Check for non-key to non-key dependencies (3NF).
  • Draw the resulting tables with primary and foreign keys.

Narrating these steps out loud is exactly what the interviewer is grading.

Quick Check

Test your grasp of the normal forms.

Recap: Normalization Through 3NF

You can now answer the staple normalization interview question end to end:

  • Normalization removes update, insert, and delete anomalies by cutting redundancy.
  • 1NF: atomic values, no repeating groups.
  • 2NF: no partial dependency on a composite key.
  • 3NF: no transitive (non-key to non-key) dependency.
  • Summarize as "the key, the whole key, and nothing but the key."
  • BCNF tightens 3NF; denormalize deliberately for read-heavy analytics.

Frequently asked questions

Is the “Normalization Through 3NF” lesson free?

Yes — the full text of “Normalization Through 3NF” is free to read here on the web, and the SQL Interview Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the SQL Interview Prep course, upgrade to CoddyKit PRO.

What will I learn in “Normalization Through 3NF”?

First, second, and third normal form with the anomalies they remove. You practise SQL Interview Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start SQL Interview Prep?

No prior experience is required. SQL Interview Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Normalization Through 3NF” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this SQL Interview Prep lesson?

Yes. Every SQL Interview Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Normalization Through 3NF
  2. ER Modeling and Relationship Cardinality
  3. Star Schema and Data Warehouse Design
  4. Full Mock Interview Problem Set
← Back to SQL Interview Prep