Normalization in SQL: 1NF, 2NF and 3NF Explained With One Example

7 min read

Normalization is the process of splitting a database into tables so that each fact is stored in exactly one place. It is done in stages called normal forms: first normal form (1NF) makes every cell hold a single value, second normal form (2NF) removes columns that depend on only part of the key, and third normal form (3NF) removes columns that depend on another non-key column. Most business databases are designed to 3NF.

The point is not tidiness. A table that stores the same fact in several rows will eventually hold two different versions of it, and every report built on it will be wrong in a way nobody notices. This lesson takes one messy order sheet from a textile wholesaler through 1NF, 2NF and 3NF, shows the problems each step removes, then covers BCNF and why analytics warehouses often undo some of it on purpose.

The normal forms at a glance

Each normal form includes the ones before it: a table in 3NF is also in 2NF and 1NF.

Normal form The rule What it removes Typical fix
1NF Every cell holds one value, and every row is unique Lists inside a cell, repeating columns such as item1, item2, item3 One row per item, with a key
2NF 1NF, and no non-key column depends on only part of a composite key Partial dependency Move those columns to a table keyed by that part
3NF 2NF, and no non-key column depends on another non-key column Transitive dependency Move those columns to a table keyed by the column they depend on
BCNF Every column that determines another column is a candidate key Rare leftovers that 3NF allows Split again around the determining column

The short version that gets quoted in interviews: every non-key column must depend on the key (1NF), the whole key (2NF), and nothing but the key (3NF).

The starting point: an order sheet

A Surat textile wholesaler sells sarees, kurtas and dupattas to retailers in other cities. For years the orders lived in a spreadsheet, one row per order, with all the items typed into one cell. Prices, which appear once the items are split out, are in rupees per piece.

order_id order_date retailer city items
1001 2026-10-02 Shree Fabrics Jaipur Banarasi saree (2), Cotton kurta (5)
1002 2026-10-05 Lakshmi Silks Indore Cotton kurta (10), Chiffon dupatta (8)
1003 2026-10-09 Shree Fabrics Jaipur Chiffon dupatta (6)
1004 2026-10-12 Kapoor Garments Ludhiana Banarasi saree (4), Cotton kurta (12)

This sheet cannot answer “how many cotton kurtas did we sell in October?” without someone reading the items text by hand. SQL cannot SUM a number that is buried inside a sentence.

Step 1: first normal form (1NF)

1NF has two requirements. Each cell holds one atomic value, so the items list has to be split into one row per product. And each row must be identifiable, so the table needs a key.

After splitting, a row is one product line within one order. Neither order_id nor product_id is unique on its own any more, but the pair is, so the key is the composite (order_id, product_id). The order date is left out below to keep the table narrow; it behaves exactly like retailer_id.

order_id retailer_id retailer_name city product_id product_name qty unit_price
1001 R1 Shree Fabrics Jaipur P1 Banarasi saree 2 2400
1001 R1 Shree Fabrics Jaipur P2 Cotton kurta 5 450
1002 R2 Lakshmi Silks Indore P2 Cotton kurta 10 450
1002 R2 Lakshmi Silks Indore P3 Chiffon dupatta 8 300
1003 R1 Shree Fabrics Jaipur P3 Chiffon dupatta 6 300
1004 R3 Kapoor Garments Ludhiana P1 Banarasi saree 4 2300
1004 R3 Kapoor Garments Ludhiana P2 Cotton kurta 12 450

Now SUM(qty) WHERE product_name = ‘Cotton kurta’ works: 27 kurtas. But look at what is repeated. “Shree Fabrics, Jaipur” appears three times, “Cotton kurta” three times. Each repeat is a chance for the copies to disagree. This is the problem the next two steps solve, and it shows up as three anomalies:

  • Update anomaly. Shree Fabrics moves to Ajmer. Someone changes two of its three rows and misses the third. The database now says the retailer is in two cities at once, and a city-wise sales report splits its revenue.
  • Insert anomaly. The wholesaler adds a new product, a Kanjivaram saree, before anyone orders it. There is no order_id to put it under, so it cannot be recorded without inventing a fake order.
  • Delete anomaly. Kapoor Garments cancels order 1004 and the rows are deleted. Kapoor Garments, its city, and the fact that it was ever a customer disappear with them.

Step 2: second normal form (2NF)

2NF applies when the key is composite. It says every non-key column must depend on the whole key, not on part of it.

Check each column against (order_id, product_id):

Column Depends on Problem
retailer_id, retailer_name, city, order_date order_id only Partial dependency
product_name product_id only Partial dependency
qty order_id and product_id together None; this is a fact about one product in one order
unit_price order_id and product_id together None; see the note below

Move each group to a table keyed by the column it depends on. That gives three tables: orders, products and order_items.

Table Columns Key
orders order_id, order_date, retailer_id, retailer_name, city order_id
products product_id, product_name, list_price product_id
order_items order_id, product_id, qty, unit_price order_id and product_id

Product names are now stored once. A product can exist in the products table before anyone orders it, which fixes the insert anomaly for products.

A note on unit_price, because it is a real design decision and a good interview answer. Order 1004 sold Banarasi sarees at 2,300, not the usual 2,400, because Kapoor Garments negotiated a discount. If price lived only in the products table, that order’s revenue would be recalculated wrongly the moment anyone changed the list price. So the price actually charged belongs in order_items, where it depends on the whole key, and the current list price belongs in products. They look like duplicates and are two different facts.

Step 3: third normal form (3NF)

3NF says no non-key column may depend on another non-key column. That kind of chain is called a transitive dependency.

The orders table still has one. retailer_name and city depend on retailer_id, and retailer_id depends on order_id. They describe the retailer, not the order. Shree Fabrics still appears in two order rows, so the update and delete anomalies for retailers have not gone away.

Move the retailer columns into their own table:

Table Columns Key Links to
retailers retailer_id, retailer_name, city retailer_id
orders order_id, order_date, retailer_id order_id retailers
products product_id, product_name, list_price product_id
order_items order_id, product_id, qty, unit_price order_id and product_id orders, products

The retailers table now holds three rows, one per retailer:

retailer_id retailer_name city
R1 Shree Fabrics Jaipur
R2 Lakshmi Silks Indore
R3 Kapoor Garments Ludhiana

All three anomalies are gone. Shree Fabrics moving to Ajmer is a one-row update. A new retailer can be added before it orders. Deleting an order leaves the retailer in place. The links between tables are foreign keys, and with them declared, the database refuses an order for a retailer_id that does not exist: an insert with retailer R9 fails with a foreign key error. Our lesson on primary keys and foreign keys in SQL covers those constraints in detail, and the CREATE TABLE statements that build each table are in DDL commands in SQL.

Getting the report back: joins

Normalization spreads a fact across tables, so analysis pulls it back together with joins. Revenue by retailer from the four 3NF tables:

Part SQL
Columns SELECT r.retailer_name, r.city, COUNT(DISTINCT o.order_id) AS orders, SUM(i.qty * i.unit_price) AS revenue
Start from retailers FROM retailers r
Add orders JOIN orders o ON o.retailer_id = r.retailer_id
Add order lines JOIN order_items i ON i.order_id = o.order_id
Group and sort GROUP BY r.retailer_id, r.retailer_name, r.city ORDER BY revenue DESC
retailer_name city orders revenue
Kapoor Garments Ludhiana 1 14600
Shree Fabrics Jaipur 2 8850
Lakshmi Silks Indore 1 6900

Note COUNT(DISTINCT o.order_id). After the join to order_items, Shree Fabrics has three rows, one per product line, so a plain COUNT would say three orders. Counting at the wrong level after a join is the most common error analysts make on normalized data; our SQL joins guide covers how joins multiply rows.

Beyond 3NF: BCNF, 4NF and 5NF

Boyce-Codd normal form (BCNF) tightens 3NF for an unusual case: a table with overlapping candidate keys, where a non-key column determines part of a key. The textbook example is a coaching institute in which each faculty member teaches exactly one subject and each student takes each subject with one faculty member. A table of (student, subject, faculty) is in 3NF, yet faculty determines subject, and faculty is not a key. Splitting it into (faculty, subject) and (student, faculty) reaches BCNF.

4NF and 5NF deal with independent multi-valued facts and join dependencies. They come up in database design courses and almost never in analyst work. For interviews, know 1NF to 3NF thoroughly and be able to state what BCNF adds.

Denormalization: why warehouses undo some of it

Normalization is the right design for systems that write data all day, such as an order system taking thousands of orders an hour. Each fact in one place makes writes safe.

Analytics has the opposite workload: few writes, many large reads. A report that joins eight normalized tables on every refresh is slow. So data warehouses deliberately denormalize into a star schema: one large fact table (one row per order line, with quantities and amounts) surrounded by dimension tables (retailer, product, date) that repeat descriptive columns freely. Power BI models and tools such as Snowflake and BigQuery are built around this shape.

Normalized (3NF) Denormalized (star schema)
Built for Recording transactions Reading and reporting
Each fact stored Once Sometimes repeated
Joins per report Many Few
Risk Slow, complex queries Copies drifting out of sync if loads are careless
Where you meet it The app’s production database The warehouse and BI model

As an analyst you will usually query both: the warehouse for dashboards, and the normalized source when a warehouse number looks wrong and you need to check it.

Mistakes people make with normalization

Treating a comma-separated list as one value. “P1,P2,P5” in a column breaks 1NF, and every query on it becomes a LIKE ‘%P2%’ search that also matches P25.

Moving a fact that only looks duplicated. The price charged on an order and the product’s current price are different facts. Normalizing them into one column destroys order history.

Normalizing for its own sake. Splitting a pincode into a separate table to remove the city that depends on it is valid 3NF and usually not worth it. Stop where the anomalies stop costing you.

Forgetting the foreign keys. Splitting tables without declaring the links lets orphan rows in, such as orders for retailers that no longer exist.

Normalization questions appear in nearly every fresher round; our SQL interview questions include them, and the SQL database types guide explains how relational databases, where normalization applies, differ from NoSQL stores, where it mostly does not.

Frequently asked questions

What is normalization in SQL?

Normalization is the process of organising a relational database into tables so that each fact is stored once, linked by primary and foreign keys. It removes redundant data and prevents update, insert and delete anomalies. It is done in stages called normal forms, usually up to third normal form.

What are 1NF, 2NF and 3NF?

1NF requires each cell to hold a single value and each row to be unique. 2NF additionally requires every non-key column to depend on the whole primary key, which matters when the key has more than one column. 3NF additionally requires that no non-key column depends on another non-key column, so every column describes the key and nothing else.

What is the difference between 2NF and 3NF?

2NF removes partial dependencies, where a column depends on only part of a composite key, such as a product name depending only on product_id in an order-lines table. 3NF removes transitive dependencies, where a column depends on another non-key column, such as a retailer’s city depending on retailer_id inside an orders table.

What is BCNF?

Boyce-Codd normal form is a stricter version of 3NF. It requires that every column which determines another column is a candidate key. Most tables in 3NF are already in BCNF; the difference appears only in tables with overlapping candidate keys, which are uncommon in business data.

What are anomalies in a database?

Anomalies are problems caused by storing the same fact in several places. An update anomaly is when changing a fact in one row but not another leaves the data contradictory. An insert anomaly is when you cannot record something without unrelated data, and a delete anomaly is when deleting one row removes a fact you needed.

Is normalization always good?

No. It is the right choice for transactional databases that are written to constantly, because it keeps data consistent. For analytics and reporting, warehouses often denormalize into star schemas so that queries need fewer joins and run faster. The trade-off is that the load process must keep repeated values in sync.

Learn to read the database you are given

Analysts rarely design databases from scratch, but they constantly query normalized ones, and knowing why the data is split the way it is tells you which joins are safe and which ones will double-count.

SkilloVilla’s SQL: Beginner to Advanced course covers creating databases, aggregation, joins and advanced SQL statements, taught in live classes with mentor support and practice on SQL playgrounds. If you want SQL as part of a full analyst programme with Excel, Python, Power BI and placement support, see the Data Analytics with Python track.

Statistics for Data Analytics: The Topics an Analyst Needs,…

Statistics for data analytics: the topics an analyst uses, grouped into a learning path, with the business question each answers and a study plan.
SkilloVilla Team
6 min read

Standard Deviation and Variance for Data Analysts, With Worked…

Standard deviation and variance for data analysts: population vs sample (n vs n-1), a worked calculation, Excel and SQL functions, and what it means.
SkilloVilla Team
7 min read

Power BI vs Tableau: Which to Learn for an…

Power BI vs Tableau compared for Indian job-seekers: job demand, cost, learning curve, data prep, Mac support and sharing, with a side-by-side table.
SkilloVilla Team
5 min read

Leave a Reply