Resources | Subject Notes | Computer Science
This section explains the concept of Third Normal Form (3NF) in database design and how to determine if a set of database tables adheres to this normal form. Understanding 3NF is crucial for designing efficient and data-integrity-focused database schemas.
Normalization is a database design technique that organizes data to reduce redundancy and improve data integrity. It involves dividing larger tables into smaller, more manageable tables and defining relationships between them. Each normal form (1NF, 2NF, 3NF, etc.) builds upon the previous one, imposing stricter rules on the structure of the tables.
A table is in 3NF if it meets the following conditions:
Let's break down these conditions:
Adhering to 3NF offers several benefits:
To determine if a table is in 3NF, you need to:
Consider the following table:
EmployeeID | EmployeeName | DepartmentID | DepartmentName |
---|---|---|---|
1 | Alice | 10 | Sales |
2 | Bob | 20 | Marketing |
In this table:
Here, DepartmentName is dependent on DepartmentID, which is a non-key attribute. Therefore, there is a transitive dependency (EmployeeID -> DepartmentID -> DepartmentName). This table is not in 3NF.
To achieve 3NF, we would decompose this table into two tables:
EmployeeID | EmployeeName | DepartmentID |
---|---|---|
1 | Alice | 10 |
2 | Bob | 20 |
DepartmentID | DepartmentName |
---|---|
10 | Sales |
20 | Marketing |
Now, each table is in 3NF. The `DepartmentName` is directly dependent on `DepartmentID` in the `Departments` table, and there are no transitive dependencies.
3NF is a crucial normal form in database design that helps to eliminate data redundancy and improve data integrity. By ensuring that non-key attributes are not transitively dependent on the primary key, we can create more robust and efficient database schemas.