BCNF is a stronger version of 3NF.
A relation is in BCNF if for every non-trivial functional dependency (X → Y), X must be a superkey.
Before BCNF (In 3NF, but Violates BCNF)
Student_ID (PK) | Subject (PK) | Professor |
|---|---|---|
101 | SQL | Dr. Sharma |
101 | Python | Prof. Verma |
102 | SQL | Dr. Sharma |
103 | SQL | Dr. Rao |
Why it passes 3NF: There are no partial or transitive dependencies on non-prime attributes because
Subjectis part of the candidate key(Student_ID, Subject).Why it fails BCNF: In the dependency
Professor → Subject,ProfessordeterminesSubject, yetProfessoris not a superkey (Dr. Sharma appears twice).The Anomalies: If Dr. Rao leaves the university and student 103 drops SQL, deleting that row erases the fact that Dr. Rao teaches SQL (delete anomaly). Also, "SQL" is stored repeatedly alongside Dr. Sharma's name (redundancy).
After BCNF (Decomposed into 2 Tables)
To reach BCNF, separate the offending dependency (Professor → Subject) into its own table where Professor is the primary key.
1. Professor_Subject Table (Professor is the primary key)
Professor (PK) | Subject |
|---|---|
Dr. Sharma | SQL |
Prof. Verma | Python |
Dr. Rao | SQL |
2. Student_Professor Table (Student_ID, Professor is the composite primary key)
Student_ID (PK, FK) | Professor (PK, FK) |
|---|---|
101 | Dr. Sharma |
101 | Prof. Verma |
102 | Dr. Sharma |
103 | Dr. Rao |
Q45. Difference between 2NF and 3NF?
2NF | 3NF |
|---|---|
Removes partial dependency | Removes transitive dependency |
Must satisfy 1NF | Must satisfy 2NF |
Focuses on composite keys | Focuses on non-key dependencies |