Boyce Codd Normal Form (BCNF)
Boyce Codd Normal Form (BCNF)
(BCNF)
More on Third Normal Form
• A relation R is automatically in 3 NF if one of the following holds
(i) R has two attributes
(ii) If 2 NF relation has only one non-key attribute
• If X →A is functional dependency in R then R is in 3 NF if one of the following
holds
(i) X is super key
(ii) A is contained in the super key or A is prime attribute
• If X → A is functional dependency in R then R is not in 3 NF if one the following
holds
(i) X is non prime attribute and A is non prime attribute
(ii) X is prime attribute and A is non prime attribute
Third Normal Form
Stu_ID City Status
• Example 1 Kolkata 1
2 Delhi 1
❖ Student_City (Stu_ID, City, Status) (already in 2NF)
3 Delhi 1
• Primary key: Stu_ID 4 Kanpur 4
• FDs: Stu_ID → City, City → Status 5 Durgapur 7
• Transitive FD: Stu_ID → Status (as Stu_ID → City, City → Status)
• Therefore, Student_City is not in 3 NF as it has transitive functional dependency
• We decompose the relation into relations which comply with 3 NF
Student City_info
Student (Stu_ID, City) (PK: Stu_ID) Stu_ID City City Status
City_info ( City, Status) (PK: City) 1 Kolkata Kolkata 1
2 Delhi Delhi 1
Above two relations (Student, City_info) are 3 Delhi Kanpur 4
1. 3 NF 4 Kanpur Durgapur 7
2. Lossless decomposition 5 Durgapur
3. Dependency preserving
Redundancy In 3 NF
• Relation in 3 NF has certain redundancy
• Example:
Let R =( SID, Advisor, Deptname) with FDs:
(i) SID, Deptname → Advisor
(ii) Advisor → Deptname
• Relation R is in 3 NF as (a) candidate key for R = (SID, Deptname) and for first FD: X → A, X is
candidate key, (b) for second FD: X →A , A is contained in the candidate key
SID Advisor Deptname
101 DRK CSE
102 DRK CSE
103 DRK CSE
104 JD BT
• (DRK, CSE) in R is repeated multiple times. So, there is redundancy. This redundancy can
cause update anomaly
Boyce Codd Normal Form (BCNF)
• However, 3 NF is adequate for database design, still 3 NF does not remove
redundancy ( discussed in previous slide)
• BCNF is used to remove possible redundancy from the relation
• BCNF is extension of 3 NF and more stronger than 3 NF
• Every relation that is in BCNF, is also in 3 NF. However, relation in 3NF may
not be in BCNF
• If X is a super key, there cannot be two tuples with same value of X – Hence,
BCNF eliminates redundancy
BCNF Example 1
• Let, Student (SID, Course, Advisor) SID Course Advisor
1 CSC01 E01
• Candidate key: (SID, Course)
1 ME01 E03
We assume that,
2 BT01 E02
An advisor takes only one course 3 CSC01 E01
A course can be taught by many advisors 3 BT01 E02
• Relation R (J, K, L)
FDs: { J, K} → L
L→K
Candidate key: {J,K} , { J, L}
• R is already in 3 NF
• R is not in BCNF for L → K as L is not candidate key
• Decompose R:
R1 ( L, K) and R2 (J, L)
• FD: L → K is preserved in R1. But, R fails to preserve {J, K} → L
• This implies: testing for {J, K} → L requires a join
• R is not in BCNF
• It is better in 3 NF since all dependencies are preserved in R
Decomposition into BCNF
• Let R ( A,B,C,D,E) , FD: { A → BC, C →DE}
• Look at FD: A → BC. Is A key? Answer is yes. So FD does not violate BCNF rule
• Look at FD: C → DE. Is C key? No. So, FD violates BCNF rule. We decompose R into R1
(C,D,E) and R2 ( A, B, C) i.e., creating sub schemas , one with attributes of violating
FD and the other with the original attributes minus RHS of violating FD