Careeroza
Second Normal Form (2NF)
Rules of 2NF
- The table is in 1NF.
- No partial dependency: every non-key column depends on the whole primary key, not just part of it.
Note: 2NF only matters for tables with a composite primary key. A table in 1NF with a single-column key is automatically in 2NF.
Example
Not in 2NF. Key = (OrderID, ProductID), but ProductName depends only on ProductID:
| OrderID | ProductID | ProductName | Quantity |
|---|---|---|---|
| 101 | 1 | Basmati Rice 5kg | 10 |
| 105 | 1 | Basmati Rice 5kg | 6 |
In 2NF: move product facts to their own table.
| OrderID | ProductID | Quantity |
|---|---|---|
| 101 | 1 | 10 |
| 105 | 1 | 6 |
| ProductID | ProductName |
|---|---|
| 1 | Basmati Rice 5kg |
This is exactly how the demo database separates OrderDetails from Products.