# Normalization and Functional Dependencies

> Use functional dependencies and closures to find keys, and normalise tables through 1NF, 2NF, 3NF and BCNF to remove redundancy and anomalies. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/cs-fundamentals/normalization
Last updated: 2026-11-28

Use functional dependencies and closures to find keys, and normalise tables through 1NF, 2NF, 3NF and BCNF to remove redundancy and anomalies.

Intermediate · about 6 hours · difficulty 3/5

Learn first: [Relational Model and ER Design](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/relational-model-er)

Normalization is the theory behind "good" schemas. It is heavily tested in written placement rounds and GATE-style questions, and interviewers like to ask why a denormalised table causes bugs.

### Why normalise

A table like `orders(order_id, customer_name, customer_phone, product, price)` repeats customer data. That causes:

- **Update anomalies**: change a phone number in one row and not another.
- **Insert anomalies**: cannot add a customer without an order.
- **Delete anomalies**: deleting the last order loses the customer.

### Functional dependencies

- `A -> B` means knowing A determines B.
- The **closure** of a set of attributes (A+) is everything it determines. If A+ contains all attributes, A is a super key. This is how you find candidate keys in exam questions.
- **Prime attributes** are part of some candidate key.

### Normal forms

- **1NF**: atomic values, no repeating groups.
- **2NF**: 1NF and no **partial dependency** (a non-prime attribute depending on part of a composite key).
- **3NF**: 2NF and no **transitive dependency** (non-prime depends on another non-prime). Formal test: for every FD X -> A, X is a super key or A is prime.
- **BCNF**: for every FD X -> A, X is a super key. Stricter than 3NF; a BCNF decomposition may lose dependency preservation.
- 4NF and 5NF deal with multivalued and join dependencies (optional).

### Decomposition properties

**Lossless join** (you can rebuild the original table) is mandatory; **dependency preservation** is desirable.

### In the real world

Production systems usually aim for 3NF, then **denormalise deliberately** for read performance (for example, caching an order total), accepting the cost of keeping copies consistent.

Good enough to move on: given a relation and a set of FDs, you can find all candidate keys, state the highest normal form, and decompose it into BCNF.

## Key concepts

- **Update, insert and delete anomalies**
- **Functional dependencies**
- **Attribute closure and finding keys**
- **1NF, 2NF, 3NF**
- **BCNF**
- **Lossless join and dependency preservation**
- **Denormalization trade-offs**
- **4NF and 5NF**

## Mini project

Take a single wide spreadsheet of college placement data (student, branch, HOD, company, package, round), list its functional dependencies, and normalise it step by step to BCNF, documenting the anomaly each step removes.

## Check yourself

For R(A, B, C, D) with A -> B and B -> C, what is the candidate key, what normal form is R in, and how would you decompose it?

## Free resources

- [GeeksforGeeks: Normal Forms in DBMS](https://www.geeksforgeeks.org/normal-forms-in-dbms/) (GeeksforGeeks)
- [CMU 15-445 Intro to Database Systems](https://15445.courses.cs.cmu.edu/) (CMU)

Previous: [SQL for Interviews](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/sql-for-interviews) · Next: [Transactions, ACID and Concurrency Control](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/transactions-and-concurrency)

## More in Database Management Systems

- [Relational Model and ER Design](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/relational-model-er)
- [SQL for Interviews](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/sql-for-interviews)
- [Normalization and Functional Dependencies](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/normalization)
- [Transactions, ACID and Concurrency Control](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/transactions-and-concurrency)
- [Indexing and Query Performance](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/indexing-and-query-optimization)
- [NoSQL Databases](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/nosql-databases)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [CS Fundamentals and Placement Prep Roadmap](https://www.internhack.in/roadmaps/tracks/cs-fundamentals)
