26.2 KB · commit 40bb182
← Previous: T08.8b: Table Normalization Walkthroughs II (2020 & 2023) | 🏠 Index | Next: T08.10: Pros and Cons of Normalization & Denormalization →
Topic: T08 — Normalization & Functional Dependencies | Priority: 🟢 | Exam Frequency: 0/7 finals (+ CT-03) (6 marks) Sources: Silberschatz 7e Ch. 7 (§7.3.1, §7.3.3, §7.5.1) · Lecture Deck 06 (Slides 41–46) · Classnote by Raidah (pp. 22–23)
Boyce-Codd Normal Form (BCNF) is a stricter version of Third Normal Form (3NF) that eliminates all redundancy caused by functional dependencies. While 3NF has a special "escape clause" that allows a non-superkey on the left-hand side of a dependency if the right-hand side is part of a candidate key, BCNF closes that loophole completely. In RUET exams and class tests, you will be asked to find the highest normal form a relation satisfies, prove why every BCNF relation is in 3NF (but not vice versa), and explain why designers sometimes settle for 3NF to preserve dependencies.
Boyce-Codd Normal Form (BCNF): A relation schema R is in Boyce-Codd Normal Form (BCNF) with respect to a functional dependency set F if, for every functional dependency α→β in F+ (where α⊆R and β⊆R), at least one of the following holds:
- α→β is a trivial functional dependency (β⊆α).
- α is a superkey for schema R. BCNF eliminates all redundancy caused by functional dependencies.
Third Normal Form (3NF): A relation schema R is in Third Normal Form (3NF) with respect to F if, for every functional dependency α→β in F+, at least one of the following holds:
- α→β is a trivial functional dependency (β⊆α).
- α is a superkey for R.
- Each attribute A in β−α belongs to a candidate key for R (is a prime attribute).
Determinant: A determinant is the attribute or set of attributes α on the left-hand side of a functional dependency α→β. In BCNF, every determinant of a non-trivial functional dependency must be a superkey.
Imagine a table where two candidate keys overlap, such as (Student, Course) and (Student, Instructor). Because every attribute belongs to at least one candidate key, every attribute is a prime attribute. Now suppose each instructor only teaches one course (Instructor→Course). Every time Professor Rahim advises a new student in Database Systems, we have to repeat the fact that Professor Rahim teaches Database Systems. Even though this table has obvious redundancy, it still passes 3NF because Course is a prime attribute!
Raymond F. Boyce and Edgar F. Codd introduced BCNF in 1974 to fix this exact loophole.
In plain English, a relation is in BCNF if and only if:
Every determinant of a non-trivial FD is a superkey.Whenever you see a non-trivial functional dependency α→β, ask one question: Is the left-hand side α a superkey of R?
+-------------------------------------------------------------+
| BCNF Condition |
| |
| For every non-trivial FD: α → β |
| |
| Condition: α MUST be a Superkey of R |
| |
| (No prime-attribute escape clause permitted) |
+-------------------------------------------------------------+
The entire difference between 3NF and BCNF comes down to the third condition of 3NF.
For any non-trivial dependency α→β, 3NF allows two ways to pass:
Why does 3NF include this second rule (often called the "escape clause")? Because without it, splitting a table with overlapping candidate keys can break a functional dependency across two separate tables. BCNF keeps rule 1 and throws out rule 2 completely, choosing zero redundancy over keeping all dependencies in one place.
| Feature | Third Normal Form (3NF) | Boyce-Codd Normal Form (BCNF) |
|---|---|---|
| Strictness | Less strict | Strictly stronger |
| Condition on α→β | α is superkey OR β is prime | α MUST be a superkey |
| Allows overlap anomalies? | Yes, if overlapping candidate keys exist | No, all FD redundancy is eliminated |
| Lossless-join decomposition | Always achievable | Always achievable |
| Dependency preservation | Always guaranteed | Not always guaranteed |
Suppose a relation R is in BCNF. That means for every non-trivial functional dependency α→β in F+:
α is a superkey of RNotice that this is the exact first condition of 3NF! Since 3NF only requires condition 1 or condition 2 to hold, any table that passes BCNF automatically passes 3NF:
BCNF⊂3NFIn short, every BCNF relation is in 3NF, but a 3NF relation is not necessarily in BCNF (specifically when an FD uses the prime-attribute escape clause).
Follow this systematic 4-step checklist on any exam problem.
Step 1: Check 1NF
└── Are all attribute values atomic?
├── No → Unnormalized (0NF)
└── Yes → Relation is at least in 1NF. Proceed to Step 2.
Step 2: Check 2NF
└── Find all Candidate Keys (CKs). Identify prime and non-prime attributes.
└── Does any non-prime attribute depend on a proper subset of a CK?
├── Yes → Partial dependency exists. Highest NF is 1NF.
└── No → Relation satisfies 2NF. Proceed to Step 3.
Step 3: Check 3NF
└── Does any non-prime attribute depend on another non-prime attribute?
├── Yes → Transitive dependency exists. Highest NF is 2NF.
└── No → Check every non-trivial FD α → β:
Is α a superkey OR is β - α composed of prime attributes?
├── No → Fails 3NF. Highest NF is 2NF.
└── Yes → Relation satisfies 3NF. Proceed to Step 4.
Step 4: Check BCNF
└── For every non-trivial FD α → β:
Is α a superkey of R?
├── Yes (for ALL FDs) → Highest NF is BCNF.
└── No (at least one non-superkey α) → Highest NF is 3NF.
Let's trace a quick 3-attribute example to see how overlapping candidate keys trigger the 3NF escape clause. (Note: The 4-attribute Lecture Deck 06 Slide 40/43 counterexample R(A,B,C,D) is solved in full in GQ2 below.)
Suppose we have a relation R(X,Y,Z) with functional dependencies:
F={XY→Z,Z→Y}This scenario corresponds to Lecture Deck 06 Slide 42 and Silberschatz 7e §7.3.1.2.
A university tracking student advisement uses the relation:
R(Student,Course,Instructor)Rules:
Compute closures:
Prime attributes: {Student,Course,Instructor}. All attributes are prime.
3NF Check:
BCNF Check:
When a relation R violates BCNF, we decompose it into smaller relations that satisfy BCNF.
Input: Schema R, set of functional dependencies F
Output: A set of schemas {R1, R2, ..., Rk} in BCNF with a lossless join
Result := {R};
done := false;
compute F+;
while (not done) do
if (there is a schema Ri in Result that is not in BCNF) then
begin
choose a non-trivial dependency α → β holding on Ri such that:
1. α ∩ β = ∅
2. α is not a superkey for Ri
Result := (Result - {Ri}) ∪ {(α ∪ β), (Ri - (β - α))};
end
else
done := true;
When we split R using a violating dependency α→β into:
R1=α∪βandR2=R−(β−α)notice that both tables keep α, while the dependent attributes (β−α) move exclusively into R1. That means the overlap between the two tables is simply α:
R1∩R2=(α∪β)∩(R−(β−α))=αBecause α→β holds, α determines all attributes of R1=α∪β:
(R1∩R2)→R1In other words, α is the primary key of the new lookup table R1 and acts as a foreign key in R2. Joining them back on α is guaranteed to be lossless!
While BCNF decomposition always gives you a lossless join and zero FD redundancy, it comes with a catch: it can break functional dependencies across tables.
Look at what happens when we split the university advisor schema R(Student,Course,Instructor) using the violating dependency Instructor→Course:
Both R1 and R2 are now in BCNF. However, look at our first rule:
(Student,Course)→InstructorStudent lives only in R2, while Course lives only in R1! Because neither table holds Student, Course, and Instructor together, the database cannot check whether a student has been assigned two instructors for the same course without running a JOIN (R1⋈R2) on every insert. Because joins during inserts are slow, database designers sometimes prefer to keep a schema in 3NF when preserving every dependency locally is more important than removing the last bit of redundancy.
The following table summarizes past exam questions addressing BCNF and the 3NF comparison.
| Year & Question | Marks | Scenario / Data Given | Key Result / Answer Summary |
|---|---|---|---|
| CT-03 Q.01(d) | 2 | ENROLLMENT schema with 4 FDs | Highest NF is 1NF because partial dependencies violate 2NF |
| CT-03 Q.04 | 4 | Prove "Every BCNF is in 3NF, but not vice versa" | Formal definition proof plus R(A,B,C,D) counterexample |
Appeared: CT-03 Q.01(d) — (2 marks)
Question:
Consider ENROLLMENT(StudentID,StudentName,CourseID,CourseName,InstructorID,InstructorName,Grade) with functional dependencies: StudentID→StudentName; CourseID→CourseName,InstructorID; InstructorID→InstructorName; (StudentID,CourseID)→Grade.
(d) Determine the highest normal form satisfied by the given relation. Give a proper justification.
Full Answer:
All attribute values in ENROLLMENT are single, indivisible data values. The relation contains no multi-valued attributes or repeating groups. Therefore, the relation satisfies 1NF.
Compute attribute closure to find the candidate key:
(StudentID,CourseID)+={StudentID,CourseID}∪{StudentName}(by StudentID→StudentName)∪{CourseName,InstructorID}(by CourseID→CourseName,InstructorID)∪{InstructorName}(by InstructorID→InstructorName)∪{Grade}(by (StudentID,CourseID)→Grade)={StudentID,StudentName,CourseID,CourseName,InstructorID,InstructorName,Grade}Because (StudentID,CourseID) determines all attributes and no single attribute can do so, the composite candidate key is:
Candidate Key={StudentID,CourseID}A relation is in 2NF if it is in 1NF and no non-prime attribute depends on a proper subset of any candidate key.
Examine the given dependencies:
Because partial functional dependencies exist, the relation violates 2NF.
Appeared: CT-03 Q.04 — (4 marks)
Question:
Justify the statement: "Every BCNF relation is in 3NF, but every 3NF relation is not necessarily in BCNF."
Full Answer:
Suppose a relation R is in BCNF. Then for every non-trivial functional dependency α→β, α is a superkey of R.
Because condition 1 of the 3NF definition is identical to the BCNF condition, every dependency that satisfies BCNF automatically satisfies condition 1 of 3NF. No dependency in R violates 3NF.
Therefore, every relation in BCNF is necessarily in 3NF:
BCNF⊂3NFTo prove that a 3NF relation is not necessarily in BCNF, consider the standard relation schema:
R(A,B,C,D)with functional dependency set:
F={AB→CD,D→A}Step A: Find Candidate Keys
Step B: Evaluate 3NF
Step C: Evaluate BCNF
Because relation R(A,B,C,D) is in 3NF but not in BCNF, the statement is fully justified.
Source: Silberschatz 7e · Chapter 7 (Exercise 7.21)
Exam Relevance: High-Probability Algorithmic Exam Drill
Key Tested Concept: Recursive BCNF decomposition algorithm and testing for dependency preservation.
Problem Statement:
Given relation schema R=(A,B,C,D,E) and set of functional dependencies:
F={A→BC,CD→E,B→D,E→A}
- Find all candidate keys of R.
- Decompose R into Boyce-Codd Normal Form (BCNF).
- Determine whether the resulting BCNF decomposition preserves all functional dependencies.
Model Exam-Style Solution:
Candidate Keys of R:
BCNF Violation Testing:
Decomposition Step 1:
BCNF Test on R1 and R2:
Final BCNF Decomposition:
D={R1(B,D),R2(A,B,C,E)}Dependency Preservation Check:
💡 RUET Exam Takeaway: Whenever a question asks to decompose into BCNF, always check if any FD spans across the split relations. If so, clearly declare the loss of dependency preservation!
Source: Silberschatz 7e · Chapter 7 (Exercise 7.30)
Exam Relevance: Classical Exam Theory & Proof Question
Key Tested Concept: Why BCNF does not always preserve dependencies while 3NF always does.
Problem Statement:
Explain why it is not always possible to achieve a database design that is in BCNF, is lossless-join, and preserves all functional dependencies. Provide a concrete relation schema and set of dependencies illustrating this dilemma.
Model Exam-Style Solution:
The Core Dilemma:
The Classic Counterexample (R=Street_Address, City, Zipcode):
Candidate Keys & Normal Form Analysis:
Attempting BCNF Decomposition:
Conclusion & Practical Engineering Trade-off:
💡 RUET Exam Takeaway: Memorize the (A,B,C) with {AB→C,C→B} counterexample. It is the textbook benchmark cited in almost every standard database exam paper.
← Previous: T08.8b: Table Normalization Walkthroughs II (2020 & 2023) | 🏠 Index | Next: T08.10: Pros and Cons of Normalization & Denormalization →