The Third Normal Form (3NF) is a further step in the normalization process after achieving Second Normal Form (2NF). A relation is considered to be in 3NF if:
1. It is already in 2NF:
2. No Transitive Dependencies:
Simply put, in 3NF, non-key attributes should not depend on other non-key attributes; they should only depend on the primary key.
Consider a table storing information about products sold by different vendors:
| Product_ID | Product_Name | Vendor_Name | Vendor_Address |
|------------|--------------|-------------|-----------------|
| P1 | Laptop | TechCorp | 123 Tech St. |
| P2 | Mouse | TechCorp | 123 Tech St. |
| P3 | Chair | FurniShop | 456 Furni Rd. |
In the table above, `Product_ID` is the primary key. We can see that `Vendor_Address` depends on `Vendor_Name` rather than `Product_ID`, which represents a transitive dependency.
To convert this table to 3NF, we can split it into two tables:
Product Table
| Product_ID | Product_Name | Vendor_Name |
|------------|--------------|-------------|
| P1 | Laptop | TechCorp |
| P2 | Mouse | TechCorp |
| P3 | Chair | FurniShop |
Vendor Table
| Vendor_Name | Vendor_Address |
|-------------|-----------------|
| TechCorp | 123 Tech St. |
| FurniShop | 456 Furni Rd. |
Now, the `Product` table has `Product_ID` as the primary key, and all attributes in this table depend only on the primary key. The `Vendor` table has `Vendor_Name` as its primary key, and the address in this table depends only on the vendor name.
This normalization eliminates the transitive dependency and reduces redundancy. If we need to change a vendor's address, we now only have to make the change in one place in the `Vendor` table.
To further refine the database structure, we might proceed to other normalization forms like BCNF, but 3NF is often sufficient for many practical applications and strikes a good balance between minimizing redundancy and maintaining a manageable schema.