- Published on
Solution to Exercise 2 - Normalize Employee Table to Third Normal Form (3NF)
Table of Contents
π§ Solution to Exercise 2: Normalize Employee Table to Third Normal Form (3NF)
In the previous exercise, we examined a table containing employee details along with their location information. Although the table satisfied 1NF and 2NF, it contained transitive dependencies, which violate the rules of Third Normal Form (3NF).
π Original Table: Employee Information
| Emp_ID | Emp_Name | DOB | Area | City | State | Zip |
|---|---|---|---|---|---|---|
| 101 | Alice | 1990-05-01 | Downtown | New York | NY | 10001 |
| 102 | Bob | 1988-08-12 | Midtown | New York | NY | 10002 |
| 103 | Charlie | 1992-11-23 | Central | Los Angeles | CA | 90001 |
| 104 | David | 1985-03-15 | West End | Chicago | IL | 60601 |
π Step-by-Step Analysis
β Step 1: 1NF Check
- All attributes contain atomic values.
- Each row is uniquely identified by
Emp_ID.
β Table is in 1NF
β Step 2: 2NF Check
- Primary Key:
Emp_ID(not composite). - All attributes depend directly on the primary key.
β Table is in 2NF
β οΈ Step 3: 3NF Check
To satisfy 3NF:
- The table must be in 2NF.
- There must be no transitive dependencies.
Letβs look at the dependencies:
Emp_Name,DOB, andZipdepend onEmp_IDβArea,City, andStatedepend onZip, not directly onEmp_IDβ
This introduces transitive dependencies, meaning the table is not in 3NF.
π οΈ Converting to 3NF
Weβll decompose the table into two:
π 1. Employee Table
| Emp_ID (PK) | Emp_Name | DOB | Zip |
|---|---|---|---|
| 101 | Alice | 1990-05-01 | 10001 |
| 102 | Bob | 1988-08-12 | 10002 |
| 103 | Charlie | 1992-11-23 | 90001 |
| 104 | David | 1985-03-15 | 60601 |
π Explanation:
Emp_IDis the primary key.- All attributes depend directly on
Emp_ID.
β Now in 3NF
π 2. Location Table
| Zip (PK) | Area | City | State |
|---|---|---|---|
| 10001 | Downtown | New York | NY |
| 10002 | Midtown | New York | NY |
| 90001 | Central | Los Angeles | CA |
| 60601 | West End | Chicago | IL |
π Explanation:
Zipis the primary key.Area,City, andStatedepend directly onZip.
β Transitive dependency eliminated
β Final Result: Achieved 3NF
After decomposition:
- βοΈ Transitive dependencies removed
- π Foreign key
Ziplinks the two tables - π¦ Data is cleaner, less redundant, and easier to maintain
π§ Key Takeaways
- 3NF removes indirect dependencies (transitive).
- Normalize by creating a separate table for attributes dependent on other non-key attributes.
- Maintaining foreign key relationships ensures data remains connected and consistent.
Discussion (0)
No comments yet. Be the first to start the conversation!
Discussion (0)
No comments yet. Be the first to start the conversation!