Database Normalization
1NF, 2NF, 3NF and Denormalization
Database normalization is the process of organizing relational tables so that each fact is stored exactly once. That prevents the update anomalies that redundant data causes as well as the insert and delete anomalies. The normal forms are its rules: 1NF requires single values, 2NF removes dependencies on part of a key, and 3NF removes dependencies between non-key columns. Denormalization reverses the process on purpose, copying facts to cut joins where reads matter more than writes.
What is database normalization?
Database normalization is the process of structuring relational tables so that every fact is stored once, in the table whose key identifies it. A customer's city belongs in a row keyed by the customer, a product's list price in a row keyed by the product, and an order line holds only what is true of that line. The rules that decide where a column belongs are called normal forms, and each form removes a specific kind of redundancy.
Edgar F. Codd introduced normalization along with the relational model in 1970 and defined second and third normal form in 1971. Boyce-Codd normal form followed in 1974, and Ronald Fagin added fourth normal form in 1977 and fifth in 1979. In everyday use, a schema is called normalized when its tables reach third normal form, which is where most transactional databases stop.
The payoff is integrity. When a fact has 1 home, an update changes 1 row, 2 copies can never disagree, and a row can be inserted or deleted without dragging unrelated facts with it. The cost is joins: a question that spans customers and their orders along with the products on them now reads 3 or 4 tables. That trade is why data engineers work with both shapes every day, normalized tables in the source systems and deliberately denormalized tables in the warehouse.
The normal forms at a glance
Each column holds 1 value per row, which rules out lists as well as repeating column groups
No non-key column depends on only part of a composite key
No non-key column depends on another non-key column
Every column set that determines another column is a candidate key
No table combines 2 independent multi-valued facts about 1 key
The table cannot be rebuilt by joining smaller tables with different keys
Why normalize: update, insert and delete anomalies
Redundancy is a correctness problem before it is a storage problem. Take a single order_lines table with 1 row per product on an order, 8 columns wide. Each row names the order and the product and gives the quantity. Beside those it carries the order date, then the customer with the customer's city, then the product name with its list price. With 1,000,000 order lines from 40,000 customers buying 5,000 products, each customer's city is written on an average of 25 rows and each product's name and price on 200.
An update anomaly is what happens when 1 fact changes. A customer moves, and the change is 25 row updates instead of 1. If the statement misses some rows, because a batch failed halfway or a filter was too narrow, the table now holds 2 cities for the same customer and no query can say which is right. A price correction on 1 product touches 200 rows with the same risk.
An insert anomaly is a fact that can't be stored yet. The key of the table is the order and the product together, so a product nobody has ordered has no row to live in, and neither does a customer who has signed up and not bought. A delete anomaly is the reverse: cancel the only order that contained a product and its name and list price are deleted with the order line.
Normalizing removes all 3 by giving each fact its own row. It also happens to shrink the data: the wide table stores 8,000,000 values, and the same information in third normal form stores 3,845,000, 52% fewer. On a columnar warehouse compression hides most of that difference, so the reason to normalize is integrity, and saved disk is a side effect.
Know Database Normalization the way the interviewer who asks it knows it.
Functional dependencies: the idea behind every normal form
A functional dependency says that 1 set of columns fixes the value of another. Written customer_id -> customer_city, it means that any 2 rows with the same customer_id must carry the same customer_city. The left side is called the determinant. A dependency is a rule about the business, not an observation about the rows currently in the table: every product in a sample may have a distinct price, and price still does not determine product.
A candidate key is a minimal set of columns that determines every other column in the table. A table can have several, and the primary key is the candidate key chosen to identify rows. Columns that belong to any candidate key are called prime, and the rest are non-prime. Every normal form from 2NF to BCNF is a statement about which determinants are allowed to sit to the left of a non-prime column.
For the wide order_lines table the dependencies are short to list. The order and product together fix the quantity: (order_id, sku) -> quantity. The product alone fixes its name and list price: sku -> product_name, list_price. The order alone fixes its date and customer: order_id -> order_date, customer_id. The customer fixes the city: customer_id -> customer_city. The only candidate key is (order_id, sku), and 3 of those 4 dependencies have a determinant that isn't that key. Each is a redundancy, and normalizing is the work of moving each to a table where its determinant is the key.
Writing the dependencies down first is the whole method. Once they are on the page, every normal form is the same check run against the list: for each dependency, is the left side a key of the table it sits in?
First normal form (1NF): 1 value per column, per row
A table is in first normal form when every column holds a single value in every row and every row can be identified by a key. The 2 classic violations are a list packed into 1 column and a repeating group of columns such as item_1, item_2, item_3. This orders table has the first kind, with every product on the order packed into items:
order_id customer_id customer_city items
1001 C-17 Austin KB-01 x2, MS-04 x1
1002 C-17 Austin MS-04 x3
1003 C-52 Denver KB-01 x1Nothing can be asked of items without parsing strings. Counting units of MS-04 needs a pattern match on every row, a join to a products table is impossible, and no constraint can stop an order from naming a product that doesn't exist. Repeating columns fail the same way with different symptoms: a fourth product on an order needs a schema change, and every query has to check each of the 3 columns.
The repair gives each value its own row. Each product on an order becomes 1 row, and the key becomes the order and the product together, (order_id, sku):
order_id sku quantity customer_id customer_city product_name list_price
1001 KB-01 2 C-17 Austin Keyboard 49.00
1001 MS-04 1 C-17 Austin Mouse 19.00
1002 MS-04 3 C-17 Austin Mouse 19.00
1003 KB-01 1 C-52 Denver Keyboard 49.00The table is now in 1NF, and it's full of repetition: Austin appears 3 times and the price of a mouse twice. First normal form makes the data queryable. It does nothing about redundancy, which is the job of the forms after it.
Atomic means atomic for the queries the table serves, not indivisible in the abstract. A timestamp or a street address is a single value until something needs to filter on part of it. A warehouse's ARRAY and STRUCT columns are a deliberate step outside 1NF, as are its JSON columns. They are chosen to keep child rows next to their parent, and they bring back the same costs whenever a query has to unnest them.
Second normal form (2NF): no partial dependencies
A table is in second normal form when it's in 1NF and no non-key column depends on only part of a candidate key. That kind of dependency is called a partial dependency, and it can exist only when a key has more than 1 column. A 1NF table whose only candidate key is a single column is already in 2NF.
Take an order_lines table keyed by (order_id, sku) whose other columns are order_date, customer_id, customer_city, product_name, list_price. Only quantity needs the whole key. product_name and list_price depend on sku alone. The same is true of order_date, customer_id, customer_city, which depend on order_id alone. Those are 2 groups of partial dependencies, and they're the reason a product's price repeats on every line that sells it.
The repair moves each group to a table keyed by its own determinant. products takes sku along with product_name and list_price. orders takes order_id, order_date, customer_id, customer_city. order_lines keeps order_id and sku plus quantity, with both key columns now foreign keys. That is 3 tables in place of 1, and a price change is 1 row in products instead of 200 rows of order lines.
The split is lossless: joining the 3 tables on their keys returns exactly the original rows. That property is what separates normalizing from merely cutting a table up, and it holds whenever the shared column is a key of 1 of the 2 tables being joined.
Third normal form (3NF): no transitive dependencies
A table is in third normal form when it is in 2NF and no non-key column depends on another non-key column. A dependency that reaches a column through a non-key column in the middle is called transitive: the key fixes the middle column, and the middle column fixes the last.
An orders table whose columns are order_id, order_date, customer_id, customer_city is in 2NF, because its key is a single column. It's not in 3NF. order_id determines customer_id, and customer_id determines customer_city, so the city is a fact about the customer that happens to be stored on the order. With 250,000 orders from 40,000 customers, each city still repeats on every order its customer placed.
The repair is the same move as before: the determinant becomes the key of a new table. customers takes customer_id and customer_city, and orders keeps customer_id as a foreign key. The model is now 4 tables, and each of the 4 dependencies has a key on its left side.
William Kent's guide to the 5 normal forms appeared in Communications of the ACM in 1983. It compresses 2NF and 3NF into a single line that engineers still quote: a non-key field must provide a fact about the whole key and nothing but the key. The whole key is the 2NF requirement, and nothing but the key is the 3NF one.
1NF vs 2NF vs 3NF: the same table in all 3 forms
The 3 forms are stages of 1 process, and each stage asks a narrower question of the same data. In 1NF an order table is a single wide order_lines table of 8 columns, 1 row per product per order. Removing the partial dependencies on its 2 column key gives 3 tables in 2NF, and removing the transitive dependency through the customer gives 4 tables in 3NF.


What changes between stages is which determinant is tolerated. 1NF allows any dependency as long as values are single. 2NF rejects a determinant that is part of a key, which is why products and orders leave the wide table. 3NF rejects a determinant that isn't a key at all, which is why customers leaves orders. The tables get narrower at each step, and a fact that used to repeat on many rows ends up on 1.
The forms are cumulative, so a table in 3NF is also in 2NF and 1NF, and in practice nobody normalizes in separate passes. An engineer who has listed the dependencies goes straight to the 3NF tables. The stages matter as vocabulary: they name the specific defect in a table, which is what a design review or an interviewer is asking for.
A 3NF example: the order model as 4 tables
order_lines holds 1 row per product on an order, keyed by order_id and sku together. Every non-key column depends on the whole key of its own table and on nothing else, so each city, date, name and price is stored once.
Boyce-Codd normal form (BCNF): every determinant is a key
BCNF drops the exemption 3NF leaves for key columns. A table is in BCNF when, for every dependency that isn't trivial, the left side is a candidate key or contains 1. 3NF allows a determinant that is not a key as long as the column it fixes is part of some candidate key. A table can fail BCNF and pass 3NF only when it has 2 or more candidate keys that overlap, which is why most 3NF tables are already in BCNF.
A support desk gives the standard shape. support_assignments has the columns customer_id, product, agent. Each customer has 1 agent per product, so (customer_id, product) -> agent. Each agent handles exactly 1 product, so agent -> product. The candidate keys are (customer_id, product) and (customer_id, agent), every column is part of a key, and the table is in 3NF. It still repeats the fact that an agent covers a product on every customer that agent serves, because agent is a determinant and not a key.
The BCNF split is agent_products(agent, product) and customer_agents(customer_id, agent). The repetition is gone, and so is something else: no single table now holds customer_id and product together with agent, so the rule that a customer has 1 agent per product can no longer be declared as a key. It has to be enforced by a trigger or an application check, or else by a data quality rule in the pipeline.
That lost rule makes BCNF a choice where 3NF is a default. Any table can be brought to 3NF without losing a dependency, but not every table can be brought to BCNF on the same terms. When the 2 conflict, choose by which failure costs more: a repeated fact that can drift, or a business rule the database no longer guards.
Fourth and fifth normal form (4NF, 5NF)
The forms past BCNF deal with redundancy that functional dependencies can't describe. Fourth normal form is about multi-valued facts: a key that has a list of values in 1 column and an unrelated list in another.
A data catalog shows it. A dataset has 3 tags and 2 owners, and tags have nothing to do with owners. A single dataset_tags_owners(dataset, tag, owner) table has to store every pairing to stay consistent, 3 times 2, so 6 rows for that dataset. Adding an owner means inserting 3 rows, and a query that counts tags without DISTINCT returns 6. The table is in BCNF, since all 3 columns together are its only key. 4NF splits it into dataset_tags and dataset_owners, 5 rows in total, each list stored once.
Data engineers meet the same defect from the other direction. Joining 2 independent child tables to their parent in 1 query produces exactly this cross product, and it is the usual cause of a metric that doubles after someone adds a join. The 4NF rule and the fan-out bug are the same fact.
Fifth normal form covers the rarer case where a table is free of those pairwise problems and can still be rebuilt by joining 3 or more smaller tables. It applies when a 3 way relationship is fully implied by its 2 way parts: if an agent represents a company, the company makes a product and the agent sells that product, then the agent sells that product for that company. Outside rules of that kind a 4NF table is already in 5NF. Sixth normal form, which reduces every table to a key and at most 1 other column, appears mostly in temporal modeling and in the hub and satellite structure of Data Vault.
How to normalize a table in practice
Start with the grain. Say in 1 sentence what a row of the table is: 1 product on 1 order, 1 customer, 1 login event. The columns that identify that thing are the key, and any column that describes something else is a candidate to move.
Then list the dependencies by asking of each non-key column what it is a fact about. Quantity is a fact about the order line. List price is a fact about the product. City is a fact about the customer. Group the columns by the thing they describe, give each group a table keyed by that thing, and connect the tables with foreign keys. Done this way the result is in 3NF without passing through the earlier forms by name.
Check the split by joining it back. The join of the new tables on their keys must return the original rows exactly. Fewer rows means a key was wrong, and more rows means 2 tables were joined on a column that is a key of neither.
When the table already exists and the rules are undocumented, the data can be asked. A dependency that holds in the business must hold in every row, so a grouped count of distinct values finds each place where the copies have already drifted apart. Those rows have to be reconciled before the column can move to its own table, and they're also the evidence that the move is worth making.
SQL to check whether a functional dependency holds
SELECT
customer_id,
COUNT(DISTINCT customer_city) AS cities,
COUNT(*) AS rows_affected
FROM order_lines
GROUP BY customer_id
HAVING COUNT(DISTINCT customer_city) > 1
ORDER BY rows_affected DESC;If customer_id determines customer_city, this query returns 0 rows. Every row it does return is a customer stored with more than 1 city, with the number of order lines that carry the conflict. Swap in any determinant and dependent column to check another dependency.
Normalization vs denormalization
Denormalization is the deliberate reversal of normalization: copying a fact into the table where queries read it, so the join that would fetch it never runs. It is a design decision made from a normalized starting point, with a known source for every copy. A table that was never normalized is unmodeled, and nobody knows which of its copies is the original.
The 2 are ends of a range, and the same data can sit at several points on it. Revenue by customer city over 1,000,000 order lines needs 3 joins across the 4 tables of the 3NF model: order lines to products for the price, to orders for the customer, and on to customers for the city. A star schema with 3 tables, a fact table of order lines with a customer and a product dimension, answers it with 1 join. A single wide table with the city on every row answers it with 0.


Each step toward the wide table makes the read simpler and faster, and the cost is more copies. The wide table writes each customer's city on 25 rows again, which is the update anomaly returning by choice. The difference from the unmodeled table is who carries the risk: the copies are rebuilt from the normalized tables by a pipeline, so a wrong value is fixed at the source and flows out on the next run.
The choice follows the workload. Many small writes with lookups by key favor normalized tables, where an update is 1 row and constraints guard every relationship. Large scans and aggregations favor denormalized tables, where the engine reads a few wide columns and joins little. That's the split between transactional and analytical systems, covered in OLTP vs OLAP.
Normalized vs denormalized tables at a glance
- Each fact stored
- Change a customer's city
- Joins for revenue by city
- Integrity kept by
- Fastest at
- Main risk
- Typical home
- Each fact storedOnce
- Change a customer's city1 row
- Joins for revenue by city3
- Integrity kept byKeys and constraints
- Fastest atMany small writes
- Main riskSlow multi-join reads
- Typical homeSource database
- Each fact storedOn many rows
- Change a customer's city25 rows
- Joins for revenue by city0
- Integrity kept byThe pipeline
- Fastest atLarge scans
- Main riskCopies drift apart
- Typical homeWarehouse and marts
When to denormalize, and how to do it safely
Denormalize when a measured read is too slow or too awkward, the copied fact changes rarely compared with how often it is read, and something other than a person is responsible for keeping the copy current. Miss any of the 3 and the copy becomes a liability. Kent's guide makes the same allowance, noting that there's no obligation to fully normalize all records when actual performance requirements are taken into account.
Most denormalization takes 1 of 4 forms. A copied column puts customer_city on the order so a report skips a join. A derived column stores order_total instead of summing lines on every read. A pre-joined table flattens several tables into 1 for a dashboard. A pre-aggregated table stores daily totals instead of events. All 4 repeat information that exists elsewhere, and all 4 need a rule for what happens when the source changes.
The safest copy is the one the database or the pipeline maintains. A materialized view stores the result of a join or aggregation and is rebuilt from its query, as with REFRESH MATERIALIZED VIEW in PostgreSQL, whose documentation is plain that the stored data is not always current. A dbt model or a scheduled job that rebuilds the wide table from normalized sources gives the same guarantee at warehouse scale: the copy may be stale by 1 run, and it can't be wrong in a way that persists.
Decide what the copy means before writing it. A city copied onto an order can mean where the customer lives now or where the customer lived when the order was placed. The first has to be rewritten on every move and the second must never be. That's a modeling question about history, the same one slowly changing dimensions answer in a warehouse, and settling it is most of the work of denormalizing well.
Normalization in a data warehouse: 3NF, star schema and wide tables
A data platform usually holds the same data at several levels of normalization, 1 per layer. The raw layer mirrors the source systems, which are normalized because they serve transactions. Where an integration layer exists, it may stay close to 3NF as in Bill Inmon's enterprise warehouse. It may also go further into Data Vault's hubs and links with their satellites. The presentation layer that analysts and dashboards query is dimensional or wide.
A star schema is a specific, disciplined denormalization. Its fact table is normalized: keys and measures at 1 grain, nothing else. Its dimensions are flattened on purpose, so a product row repeats its category name and a customer row repeats its region, which puts every attribute 1 join from the facts. Normalizing those dimensions back into chains of tables gives a snowflake schema, which saves little on a columnar engine and adds a join per level. Interviewers return to this trade often, and the dimensional modeling interview questions work through it.
Columnar engines changed the arithmetic that made normalization pay for itself in storage. A repeated city compresses to almost nothing in a column store, and scanning 1 wide table avoids shuffling data between workers for a join. BigQuery's documentation on nested and repeated fields recommends denormalizing with STRUCT and ARRAY columns, keeping order lines inside their order row, and in the same breath notes that star schemas are typically already optimized for analytics and that denormalizing further may not change performance much.
The practical rule for a data engineer is to keep 1 normalized, well-keyed layer as the source of truth and treat everything downstream of it as a rebuildable projection. A wide table that can be dropped and recreated from normalized models is cheap to get wrong. A wide table that is the only copy of its data has every anomaly normalization was invented to remove.
Common normalization mistakes
A surrogate key does not normalize a table. Adding an id column to a wide order_lines table gives it a single-column primary key, and by a careless reading of 2NF the partial dependencies vanish. They do not: (order_id, sku) is still a candidate key whether it's declared, and the price still repeats on every line. The normal forms are defined over all candidate keys for this reason. Declare the natural key as a unique constraint so the database keeps guarding it.
A snapshot isn't a redundancy. An order line that stores unit_price, the price actually charged, isn't violating anything even when products has list_price. The price charged depends on the order line, not on the product, and it must not change when the list price does. The same goes for a shipping address copied onto an order. Removing those columns in the name of 3NF destroys history. The question to ask is whether the value should change when the source changes.
Over-splitting is the opposite error. Moving each of city, state, zip to its own lookup table because a zip code determines a city is defensible on paper but rarely worth 3 joins on every address read, since those values almost never change. Normal forms identify where redundancy exists. Whether a given redundancy is worth removing is a judgment about how often the fact changes and what a disagreement would cost.
Normalizing every table to the highest form it can reach is a mistake of its own. The useful target is a design in which every dependency the business cares about is enforced somewhere, by a key where that is possible and by a documented check where it's not.
How normalization comes up in data engineering interviews
Interviewers rarely ask for the definition of 3NF on its own. The usual prompt is a wide table or a spreadsheet export and the instruction to model it, and what they listen for is the reasoning: the grain of each table said out loud, the dependency that justifies each split, and the point at which the candidate stops normalizing and says why.
The second half of the conversation runs the other way. Given a normalized source, design the tables an analytics team will query, and defend each place a fact is copied. Strong answers name what keeps the copy correct, state whether a copied attribute is current or as of the event, and count the joins a common query needs before and after. The data modeling round guide covers how that round is structured.
Both halves reward practice on real schemas more than recall. The data modeling interview questions cover the prompts interviewers ask about keys and grain as well as normal forms. The data modeling practice problems let you build the model on a canvas and have the design reviewed.
Database normalization FAQ
What is database normalization in simple terms?+
What is the difference between 1NF, 2NF and 3NF?+
What is the difference between normalization and denormalization?+
Is 3NF enough, or does a table need BCNF?+
Is a star schema normalized or denormalized?+
Does normalization make a database slower?+
Should a data warehouse be normalized?+
The candidate who gets the offer
- 01
Reading a solution is not the same as writing one
Every engineer who has frozen on a query they had read a dozen times knows the gap. The only preparation that closes it is producing the answer yourself, under time, before the interview does it for you
- 02
76% of hiring managers reject on the coding task, not the resume
From HackerRank's 2024 Developer Skills Report. Candidates who look strong on paper still fail the live screen if they haven't done timed, executable practice
- 03
The round is won on tradeoffs, not on the diagram
Grain, star vs snowflake, SCD type, conformed dimensions, late-arriving data. Modeling under live pushback is what separates the bands, and it is the half almost nobody rehearses
Related guides
Data modeling interview questions
The questions interviewers ask about keys and grain along with schema design
Data modeling practice problems
Schema design problems to build on the modeling canvas
Data modeling round guide
What the modeling round asks and how to prepare for it
Dimensional modeling interview questions
Facts and dimensions, plus the denormalization trade in a warehouse
Star schema
The denormalized dimensional model most warehouses present
Snowflake schema
What normalizing a star schema's dimensions costs and saves
This week's community challenge
Dirty, production-shaped data, scored blind each week.