Database Normalization: 1NF, 2NF and 3NF with Examples
Codevity Admin · 10/25/2026
Codevity Admin · 10/25/2026
Normalization is the process of organizing tables so that each fact is stored once. It reduces duplicate data and prevents the update problems that come with it. Interviewers usually ask for 1NF, 2NF and 3NF with a simple example, so this article uses one example all the way through.
Imagine a single wide table:
| order_id | customer_name | customer_city | product | unit_price | quantity |
|---|---|---|---|---|---|
| 1 | Asha | Pune | Keyboard | 25 | 1 |
| 1 | Asha | Pune | Mouse | 10 | 2 |
| 2 | Ben | Delhi | Keyboard | 25 | 1 |
Storing the same facts in many rows causes three problems:
A table is in 1NF when:
phone1, phone2, phone3),The fix for a multi-valued column is to move the values into rows (or a separate table), one value per row.
A table is in 2NF when it is in 1NF and has no partial dependency: no non-key column depends on only part of a composite key.
order_items has the composite key (order_id, product_id):
| order_id | product_id | product_name | unit_price | quantity |
|---|---|---|---|---|
| 1 | 7 | Keyboard | 25 | 1 |
product_name and unit_price depend only on product_id, which is just half of the key. Move them to their own table:
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(100) NOT NULL,
unit_price DECIMAL(10, 2) NOT NULL
);
CREATE TABLE order_items (
order_id INT NOT NULL,
product_id INT NOT NULL REFERENCES products (product_id),
quantity INT NOT NULL,
PRIMARY KEY (order_id, product_id)
);If you need the price at the time of purchase, keep a column in on purpose. That is a different fact from today's catalogue price.
A table is in 3NF when it is in 2NF and has no transitive dependency: no non-key column depends on another non-key column.
| id | name | department_id | department_name |
|---|---|---|---|
| 1 | Asha | 1 | Engineering |
depends on , which is not the key of this table. The chain is to to . Move the department into its own table and keep only here.
A memorable summary: every non-key column must depend on the key, the whole key, and nothing but the key.
Boyce-Codd normal form is a slightly stricter 3NF: for every dependency where determines , must be a key (a candidate key or a superset of one). Most 3NF tables already satisfy it. For a fresher interview, the definition is usually enough.
Denormalization adds redundancy deliberately to make reads faster, for example storing an order total on the order row, or flattening tables for reports. It is common in data warehouses and reporting databases (OLAP), where reads are heavy and data changes rarely. The cost is extra storage and the work of keeping the copies consistent. Transactional systems (OLTP) that change data constantly are normally kept in 3NF.
| Question | Short answer |
|---|---|
| 1NF | Atomic values, no repeating groups, a key |
| 2NF | 1NF plus no partial dependency on a composite key |
| 3NF | 2NF plus no transitive dependency |
| Why normalize | Less duplication and no insert, update or delete anomalies |
| Why denormalize | Faster reads and simpler reporting, at the cost of redundancy |
Take a spreadsheet you know (an invoice, a student list) and normalize it to 3NF on paper. Then check yourself with the Indexes, Design and Transactions quiz.
unit_priceorder_itemsdepartment_namedepartment_ididdepartment_iddepartment_namedepartment_idABA