A table must:
Be in 2NF.
Have no transitive dependency: every non-key attribute depends directly on the primary key, not on another non-key attribute.
Before 3NF (Violates 3NF)
Courses Table
Course_ID (PK) | Course_Title | Instructor_Name | Instructor_Office |
|---|---|---|---|
C01 | SQL Basics | Dr. Sharma | Room 302 |
C02 | Power BI | Dr. Sharma | Room 302 |
C03 | Python | Prof. Verma | Room 405 |
The Problem:
Course_IDdeterminesInstructor_Name, andInstructor_NamedeterminesInstructor_Office. BecauseInstructor_Officedepends on a non-key column (Instructor_Name) rather than directly onCourse_ID, this creates a transitive dependency.The Anomalies: If Dr. Sharma moves to a new office, you must update multiple rows (update anomaly). If you delete all courses taught by Prof. Verma, you lose the record of his office room (delete anomaly).
After 3NF (Decomposed into 2 Tables)
To reach 3NF, move the transitively dependent columns into a separate table with the determining column as its primary key.
1. Courses Table (Course_ID is the primary key)
Course_ID (PK) | Course_Title | Instructor_Name (FK) |
|---|---|---|
C01 | SQL Basics | Dr. Sharma |
C02 | Power BI | Dr. Sharma |
C03 | Python | Prof. Verma |
2. Instructors Table (Instructor_Name is the primary key)
Instructor_Name (PK) | Instructor_Office |
|---|---|
Dr. Sharma | Room 302 |
Prof. Verma | Room 405 |