Logo
Published on

Solution to Exercise 2 - Normalize Employee Table to Third Normal Form (3NF)

🧠 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_IDEmp_NameDOBAreaCityStateZip
101Alice1990-05-01DowntownNew YorkNY10001
102Bob1988-08-12MidtownNew YorkNY10002
103Charlie1992-11-23CentralLos AngelesCA90001
104David1985-03-15West EndChicagoIL60601

πŸ” 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, and Zip depend on Emp_ID βœ…
  • Area, City, and State depend on Zip, not directly on Emp_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_NameDOBZip
101Alice1990-05-0110001
102Bob1988-08-1210002
103Charlie1992-11-2390001
104David1985-03-1560601

πŸ”Ž Explanation:

  • Emp_ID is the primary key.
  • All attributes depend directly on Emp_ID.

βœ… Now in 3NF

πŸ“„ 2. Location Table

Zip (PK)AreaCityState
10001DowntownNew YorkNY
10002MidtownNew YorkNY
90001CentralLos AngelesCA
60601West EndChicagoIL

πŸ”Ž Explanation:

  • Zip is the primary key.
  • Area, City, and State depend directly on Zip.

βœ… Transitive dependency eliminated

βœ… Final Result: Achieved 3NF

After decomposition:

  • βœ‚οΈ Transitive dependencies removed
  • πŸ”— Foreign key Zip links 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.