Lecture 9 DB Normalization (2)
Lecture 9 DB Normalization (2)
Database
Normalization
COMP3278B
Introduction to Database Management Systems
Dr. Ping Luo
Email : [email protected]
Department of Computer Science, The University of Hong Kong
3
Recap Armstrong’s Axioms
2 rules in tutorial!
7. Extensivity - if → , then → .
8. Composition - if → and → , then → .
4
Attribute set closure α +
Attribute set
F = {A → B, B → C}
closure of A.
{A}+= { A, B
B,, C }
1. A →A is always true (by Reflexivity).
2. A → B is given in F.
3. A → C is derived from F:
Given A → B and B → C, A → C is also true (by Transitivity).
5
Attribute set closure α +
Attribute set
F = {A → B, B → C}
closure of A.
{A}+= { A, BB,, C }
{B}+= { B, C } Note that we only
consider single
8
FD closure F +
N→N
N→S
N→P
N→NS
FD Step 3. Use α as LHS, and generate an FD
N→NP
N→SP
for every subset of α+ on RHS.
N→NSP
11
FD closure F +
12
Concept
Decomposition
Lossless-join decomposition
Dependency preserving decomposition
Normal form
Boyce-Codd Normal Form (BCNF)
13
Motivating example
Let’s consider the following schema
Employees have eid (key), name, parkingLot.
Departments have did (key), dname, budget.
An employee works in exactly one department, since some date.
Employees who work in the same department must park at
the same parkingLot.
name dname
since budget
eid parkingLot did
Lossless-join
Decomposition
Example 1
R Functional dependencies
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
The functional dependency B→C tells us
3 2 2 that for all tuples with the same value in B,
3 1 3
4 2 2 there should be at most one corresponding
4 1 3
value in C (E.g., If B=1, C =3 ; if B=2, C=2)
Decompose Question: Will decomposing R(A,B,C) into
R1(A,B) and R2(A,C) cause information lost?
R1 = A, B(R) R2 = A, C(R)
A B A C
1 1 1 3 Think in this way:
1 2 1 2 Is this decomposition “lossless join
2 1 2 3 decomposition”?
3 2 3 2 I.e., Is there any information lost if
3 1 3 3 we decompose R in this way?
4 2 4 2
4 1 4 3 19
Example 1
R Functional dependencies R1 ⋈ R2= A, B(R) ⋈ A, C(R)
A B C F = {B →C} A B C
1 1 3 1 1 3
≠
1 2 2
To check if the
1 1 2
2 1 3 1 2 3 decomposition will cause
3 2 2 1 2 2 information lost, let’s try to
3 1 3 2 1 3
4 2 2 3 2 2 join R1 and R2 and see if we
4 1 3 3 2 3 can recover R.
3 1 2 As we see that R1 ⋈ R2 ≠ R,
Decompose 3 1 3
4 2 2 the decomposition has
4 2 3 information lost.
R1 = A, B(R) R2 = A, C(R) 4 1 2
This is NOT a lossless-join
4 1 3
A B A C decomposition.
1 1 1 3
1 2 1 2
2 1 2 3
3 2 3 2
3 1
This is a bad
3 3
4 2 4 2 decomposition
4 1 4 3
20
Example 2
R Functional dependencies R1 ⋈ R2 = A, B(R) ⋈ B, C(R)
A B C F = {B →C} A B C How about
1 1 3 1 1 3
decomposing the
=
1 2 2 1 2 2
2 1 3
2
3
1
2
3
2 3 2 2 relation R(A,B,C)
3 1 3 3
4
1
2
3
2
into R1(A,B) and
4 2 2
4 1 3 4 1 3 R2(B,C)?
Decompose
A B C F = {B →C}
1 1 3
1 2 2
2
3
1
2
3
2
What is/are the condition(s)
3 1 3
4
4
2
1
2
3
for a decomposition to be
lossless-join?
Example I Example II
NOT Lossless-join decomposition Lossless-join decomposition
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1
3 2 2
A B
1 1
3 1 3
4 2 2
Let’s consider the first
4 1 3
tuple (1,1,3) in R.
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1 2 A C
3 2 2
A B
1 1 1 3
3 1 3 1 2
4 2 2
Let’s consider the first
4 1 3 Since A →AC is NOT a
tuple (1,1,3) in R.
functional dependency
in F+, there can be more
Example I Note that there is only
than one tuples with
ONE tuple in R1 with
NOT Lossless-join A=1, B=1.
A=1 in R2
(e.g., (1,3), (1,2) ) .
decomposition
R1 = A, B(R) R2 = A, C(R)
A B A C
1 1 1 3
1 2 1 2
2 1 2 3
3 2 3 2
3 1 3 3
4 2 4 2 24
4 1 4 3
Lossless-join decomposition
R Functional dependencies
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1 2 A C
3 A B C
A B
3
3
2
1
2
3
1 1 ⋈ 1
1
3
2
= 1 1 3
1 1 2
4 2 2
Let’s consider the first
4 1 3 Since A →AC is NOT a
tuple (1,1,3) in R. Therefore when we join
functional dependency
in F+, there can be more R1 and R2, more than one
Example I Note that there is only tuples will be generated
than one tuples with
ONE tuple in R1 with (i.e., (1,1) in R1 combine
NOT Lossless-join A=1, B=1.
A=1 in R2
with (1,3) and (1,2) in R2 )
(e.g., (1,3), (1,2) ) .
decomposition
R1 = A, B(R) R2 = A, C(R)
A B A C Observation:
1 1 1 3 The decomposition of R(A,B,C) into R1(A,B) and R2(A,C)
1 2 1 2
2 1 2 3
is NOT lossless-join because
3 2 3 2 A→ AC
3 1 3 3
4 2 4 2
is NOT in F+ , and … (to be explained in the next slide)
4 1 4 3 25
Lossless-join decomposition
R Functional dependencies
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1
3 2 2
A C
1 3
3 1 3
4 2 2
Let’s consider the
4 1 3
first tuple (1,1,3) in R.
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1 2 A B
3 2 2
A C
1 1
1 3
3 1 3 1 2
4 2 2
Let’s consider the Since A →AB is NOT a
4 1 3
first tuple (1,1,3) in R. functional dependency
in F+, there can be
Example I Note that there is more than one tuples
only ONE tuple in R2 with A=1 in R1
NOT Lossless-join with A=1, C=3. (i.e., (1,1), (1,2) ) .
decomposition
R1 = A, B(R) R2 = A, C(R)
A B A C
1 1 1 3
1 2 1 2
2 1 2 3
3 2 3 2
3 1 3 3
4 2 4 2 27
4 1 4 3
Lossless-join decomposition
R Functional dependencies
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1 2 A B 3 A B C
A C
3
3
2
1
2
3
1 3 ⋈ 1
1
1
2
= 1
1
1
2
3
3
4 2 2
Let’s consider the Since A →AB is NOT a
4 1 3 Therefore when we join
first tuple (1,1,3) in R. functional dependency
in F+, there can be R1 and R2, more than one
tuples will be generated
Example I Note that there is more than one tuples
(i.e., (1,3) in R2 combine
only ONE tuple in R2 with A=1 in R1
NOT Lossless-join with A=1, C=3. (i.e., (1,1), (1,2) ) . with (1,1) and (1,2) in R1 )
decomposition
R1 = A, B(R) R2 = A, C(R)
A B A C Observation:
1 1 1 3 The decomposition of R(A,B,C) into R1(A,B) and R2(A,C)
1 2 1 2
2 1 2 3
is NOT lossless-join because
3 2 3 2 A→ AC (explained in previous slide), and
3 1 3 3 A→ AB
4 2 4 2
4 1 4 3 are NOT in F+ . 28
Lossless-join decomposition
R Functional dependencies
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1
3 2 2
A B
1 1
3 1 3
4 2 2
4 1 3 Let’s consider the
first tuple (1,1,3) in R.
Note that there is
Example II only ONE tuple in R1
Lossless-join with A=1, B=1.
decomposition
R1 = A, B(R) R2 = B, C(R)
A B B C
1 1 1 3
1 2 2 2
2 1
3 2
3 1
4 2 29
4 1
Lossless-join decomposition
R Functional dependencies
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1 2
A B B C
3 2 2
1 1 1 3
3 1 3
4 2 2
4 1 3 Let’s consider the Since B →BC is a
first tuple (1,1,3) in R. functional dependency
Note that there is in F+, there is only one
Example II only ONE tuple in R1 tuple with B=1 in R2.
Lossless-join with A=1, B=1.
decomposition
R1 = A, B(R) R2 = B, C(R)
A B B C
1 1 1 3
1 2 2 2
2 1
3 2
3 1
4 2 30
4 1
Lossless-join decomposition
R Functional dependencies
A B C F = {B →C}
1 1 3
1
2
2
1
2
3
1 2 3
A B B C A B C
3
3
2
1
2
3
1 1 ⋈ 1 3 = 1 1 3
4 2 2
4 1 3 Let’s consider the Since B →BC is a Therefore when we join R1
first tuple (1,1,3) in R. functional dependency and R2, there will be ONLY
Note that there is in F+, there is only one ONE tuple generated, and
Example II only ONE tuple in R1 tuple with B=1 in R2. that must be the
Lossless-join with A=1, B=1. corresponding tuple (1,1,3)
decomposition in R.
Dependency preserving
Decomposition
Dependency preserving
When decomposing a relation, we also want to keep
the functional dependencies.
A FD X → Y is preserved in a relation R if R contains all the
attributes of X and Y.
If a dependency is lost when R is decomposed into R1
and R2:
When we insert a new record in R1 and R2, we have to
obtain R1⋈ R2 and check if the new record violates the lost
dependency before insertion.
It could be very inefficient because joining is required in
every insertion! 35
Dependency preserving
Note that A→CD is in F+ because R
of the Transitivity axiom.
A B C D
Consider R(A,B,C,D), F = {A → B, B →CD} 1
2
1
1
3
3
4
4
F+ = {A → B, B →CD, A →CD, trivial FDs} 3
4
2
1
2
3
3
4
B C D 5 1
Inserting 1 4 4 violate any F2 in R2? Although among the two
validations we haven’t checked
This involves checking F2={B →CD}. A→CD, but since A→B is
checked in F1, and B →CD is
We can check F1 on R1 and F2 on R2 only because checked in F2, if we pass both F1
(F1 F2)+ = F+ and F2, it implies A →CD. 38
Dependency preserving
R
A B C D
What about decompose R to R1(A,B), 1
2
1
1
3
3
4
4
R2(A,C,D) ? 3
4
2
1
2
3
3
4
R is decomposed to R1(A,B) , R2(A,C,D)
Decompose
F+ = {A → B, B →CD, A →CD, trivial FDs} R1 = A, B(R) R2=A, C, D(R)
F1 = {A → B, trivials}, the projection of F+ on R1 A B A C D
1 3 4
F2 = {A → CD , trivials}, the projection of F+ on R2 12 11 2 3 4
3 2 3 2 3
4 1 4 3 4
This is NOT a dependency preserving
decomposition as:
(F1 F2)+ ≠ F+
Let us illustrate the implication of NOT
dependency preserving in the next slide. 39
Dependency preserving
R
A B C D
What about decompose R to R1(A,B), 1
2
1
1
3
3
4
4
R2(A,C,D) ? 3
4
2
1
2
3
3
4
Boyce-Codd
Normal Form
FD and redundancy
Consider the following relation: Customer
id name dptID
Customer( id, name, dptID ) 1 Kit 1
2 David 1
F = { {id} → {name, dptID} } 3 Betty 2
4 Helen 2
How to check?
Check if the attribute set closure of {dptID} covers all
attributes in Customer. ({dptID}+ = {dptID, building} ≠ Customer)
R(A, B, C, D), F = {A → B, B → C} 1
1
1
1
1
1
1
2
1 1 1 3
1 1 1 4
To test if R is in BCNF, it suffices to check 1 1 1 5
only the dependencies in F (but not F+) An example R that satisfies F
Illustration R
A B C D
R(A, B, C, D), F = {A → B, B → C} 1
1
1
1
1
1
1
2
1 1 1 3
Is R2(A, C, D) in BCNF? 1 1 1 4
1 1 1 5
R1(A, B) R2(A, C, D)
Conclusion: When we test whether a A B A C D
decomposed relation is in BCNF, we must 1 1 1 1 1
1 1 2
project F+ onto the relation (e.g., R2), not F! 1 1 3
1 1 4
1 1 5
53
Section 4
Normalization
Normalization goal
When we decompose a relation R with a set of
functional dependencies F into R1, R2, …, Rn, we try
to meet the following goals:
1. Lossless-join – Avoid the decomposition result in
information loss.
Fx B→C A→B
61
Example 1 R1(B, C) R2(A, B)
62
Example 1 R1(B, C) R2(A, B)
Fx B→C A→B
67
Example 2
73
Question 1
Given a relation R(A,B,C) and a functional dependency {A→B} that holds on R,
which of the following statements is/are correct?
a. {A,C} is a candidate key for R.
b. The decomposition of R into R1(A,B) and R2(A,C) is a lossless-join decomposition.
c. The decomposition of R into R1(A,B) and R2(B,C) is a lossless-join decomposition.
74
Question 1
Given a relation R(A,B,C) and a functional dependency {A→B} that holds on R,
which of the following statements is/are correct?
a. {A,C} is a candidate key for R.
b. The decomposition of R into R1(A,B) and R2(A,C) is a lossless-join decomposition.
c. The decomposition of R into R1(A,B) and R2(B,C) is a lossless-join decomposition.
76
Question 1
Given a relation R(A,B,C) and a functional dependency {A→B} that holds on R,
which of the following statements is/are correct?
a. {A,C} is a candidate key for R.
b. The decomposition of R into R1(A,B) and R2(A,C) is a lossless-join
decomposition.
c. The decomposition of R into R1(A,B) and R2(B,C) is a lossless-join
decomposition.
Answer: A decomposition is lossless-join decomposition if
Question: What do we mean by the original relation can be obtained after joining the
lossless-join decomposition? decomposed relations.
78
Question 1
Given a relation R(A,B,C) and a functional dependency {A→B} that holds on R,
which of the following statements is/are correct?
a. {A,C} is a candidate key for R.
b. The decomposition of R into R1(A,B) and R2(A,C) is a lossless-join
decomposition.
c. The decomposition of R into R1(A,B) and R2(B,C) is a lossless-join
decomposition.
80
Question 2 a
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
i) Which of the following attributes is NOT in the attribute closure
of C (i.e., C+)?
A. A.
B. B. Question: What do we mean by Answer: The attribute closure of C is
C. D. the attribute closure of C? the set of attributes that can be
functionally determined by C.
D. E.
E. None of the above.
81
Question 2 a
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
i) Which of the following attributes is NOT in the attribute closure
of C (i.e., C+)?
A. A.
B. B. Question: What do we mean by Answer: The attribute closure of C is
C. D. the attribute closure of C? the set of attributes that can be
functionally determined by C.
D. E.
E. None of the above.
82
Question 2 a
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
i) Which of the following attributes is NOT in the attribute closure
of C (i.e., C+)?
A. A.
B. B. Question: What do we mean by Answer: The attribute closure of C is
C. D. the attribute closure of C? the set of attributes that can be
functionally determined by C.
D. E.
E. None of the above.
85
Question 2 b
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following functional dependencies is NOT in the closure of F
(i.e., F+)?
i. BE→D
ii. BD→ABCDE Question: What do we mean by Answer: The set of all functional
the FD closure? dependencies that can be logically
iii. AB→D
implied by F is called the closure of
iv. CE→A F (or F+).
86
Question 2 b
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following functional dependencies is NOT in the closure of F
(i.e., F+)?
i. BE→D
ii. BD→ABCDE Question: What do we mean by Answer: The set of all functional
the FD closure? dependencies that can be logically
iii. AB→D
implied by F is called the closure of
iv. CE→A F (or F+).
87
Question 2 b
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following functional dependencies is NOT in the closure of F
(i.e., F+)?
i. BE→D
ii. BD→ABCDE Question: What do we mean by Answer: The set of all functional
the FD closure? dependencies that can be logically
iii. AB→D
implied by F is called the closure of
iv. CE→A F (or F+).
88
Question 2 b
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following functional dependencies is NOT in the closure of F
(i.e., F+)?
i. BE→D
ii. BD→ABCDE Question: What do we mean by Answer: The set of all functional
the FD closure? dependencies that can be logically
iii. AB→D
implied by F is called the closure of
iv. CE→A F (or F+).
89
Question 2 b
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following functional dependencies is NOT in the closure of F
(i.e., F+)?
i. BE→D
ii. BD→ABCDE Question: What do we mean by Answer: The set of all functional
the FD closure? dependencies that can be logically
iii. AB→D
implied by F is called the closure of
iv. CE→A F (or F+).
90
Question 2 c
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following is/are candidate key(s) of R?
i. {B,E}
Question: How to show if a set
ii. {B,D} of attribute is a candidate key
iii. {C,E} or not?
91
Question 2 c
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following is/are candidate key(s) of R?
i. {B,E}
Question: How to show if a set Answer: 1) It has to be a super key.
ii. {B,D} of attribute is a candidate key 2) It has to be minimal.
iii. {C,E} or not?
92
Question 2 c
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Which of the following is/are candidate key(s) of R?
i. {B,E}
Question: How to show if a set Answer: 1) It has to be a super key.
ii. {B,D} of attribute is a candidate key 2) It has to be minimal.
iii. {C,E} or not?
94
Question 2 d
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Suppose that relation R is decomposed into R1(A,B,C,D) and
R2(A,C,E). Which of the following statements is/are correct?
i. This is a lossless-join decomposition.
ii. The decomposition is dependency preserving.
iii. R1 and R2 are in BCNF.
95
Question 2 d
Consider the relation R(A,B,C,D,E) with the following functional dependencies F =
{A→E, BCE→D, CD→BE, C→AB, BD→AC} which hold in it.
• Suppose that relation R is decomposed into R1(A,B,C,D) and
R2(A,C,E). Which of the following statements is/are correct?
i. This is a lossless-join decomposition.
ii. The decomposition is dependency preserving.
iii. R1 and R2 are in BCNF.
Answer: A decomposition is lossless-join decomposition
iff at least one of the following dependencies is in F+:
Question: How to test if a
1) common attribute of R1 and R2 → schema of R1
decomposition is lossless-join
2) common attribute of R1 and R2 → schema of R2
decomposition?
99
Question 3
Consider the schema R(A, B, C, D, E) and the set of functional dependencies
F={ D→A, C→BDE } which holds in the schema.
100
Question 3
Consider the schema R(A, B, C, D, E) and the set of functional dependencies
F={ D→A, C→BDE } which holds in the schema.
101
Question 3
Consider the schema R(A, B, C, D, E) and the set of functional dependencies
F={ D→A, C→BDE } which holds in the schema.
b) Give a lossless join decomposition of R into relations in BCNF. Is the
decomposition dependency preserving?
◼ R1 (A,D), R2 (B,C,D,E)
◼ R1 in BCNF ?
❑ F1 is the projection of F+ on R1: F1 = {D→A, and the trivial FDs}
❑ Is D a key in R1?
❑ Since D is a key in R1, all non-trivial FDs in F1 forms a key, thus R1 is in BCNF.
◼ R2 in BCNF?
❑ F2 is the projection of F+ on R2: F2 = {C→BDE, and the trivial FDs}
❑ Is C a key in R2?
❑ Since C is a key in R2, all non-trivial FDs in F2 forms a key, thus R2 is in BCNF.
Step 1. Decompose R into two relations R1 Step 2. Check if R1 and R2 are in BCNF.
and R2, and make R1 a BCNF. If not, further decompose it using
Look at D→A in F, make R1 as (A,D). Step 1.
Then R2 is (B,C,D,E). In BCNF, every non-trivial FD forms a
Why include D in R2? 102 key!
Question 3
Consider the schema R(A, B, C, D, E) and the set of functional dependencies
F={ D→A, C→BDE } which holds in the schema.
b) Give a lossless join decomposition of R into relations in BCNF. Is the
decomposition dependency preserving?
◼ R1 (A,D), R2 (B,C,D,E)
◼ R1 in BCNF ?
❑ F1 is the projection of F+ on R1: F1 = {D→A, and the trivial FDs}
❑ Is D a key in R1?
❑ Since D is a key in R1, all non-trivial FDs in F1 forms a key, thus R1 is in BCNF.
◼ R2 in BCNF?
❑ F2 is the projection of F+ on R2: F2 = {C→BDE, and the trivial FDs}
❑ Is C a key in R2?
❑ Since C is a key in R2, all non-trivial FDs in F2 forms a key, thus R2 is in BCNF.
◼ Is it a lossless-join decomposition?
❑ Common attribute among R1 and R2 = D
❑ D→R1 (i.e. AD) holds in F+ Answer: A decomposition is lossless-join decomposition iff
❑ Therefore it is a lossless-join decomposition. at least one of the following dependencies is in F+:
1) common attribute of R1 and R2 → schema of R1
2) common attribute of R1 and R2 → schema of R2
103
Question 3
Consider the schema R(A, B, C, D, E) and the set of functional dependencies
F={ D→A, C→BDE } which holds in the schema.
b) Give a lossless join decomposition of R into relations in BCNF. Is the
decomposition dependency preserving?
◼ R1 (A,D), R2 (B,C,D,E)
◼ R1 in BCNF ?
❑ F1 is the projection of F+ on R1: F1 = {D→A, and the trivial FDs}
❑ Is D a key in R1?
❑ Since D is a key in R1, all non-trivial FDs in F1 forms a key, thus R1 is in BCNF.
◼ R2 in BCNF?
❑ F2 is the projection of F+ on R2: F2 = {C→BDE, and the trivial FDs}
❑ Is C a key in R2?
❑ Since C is a key in R2, all non-trivial FDs in F2 forms a key, thus R2 is in BCNF.
◼ Is it a lossless-join decomposition?
❑ Common attribute among R1 and R2 = D
Answer: A decomposition is dependency preserving iff:
❑ D→R1 (i.e. AD) holds in F+
❑ Therefore it is a lossless-join decomposition. (F1 U F2 U …. U Fn)+ = F+
◼ Is it a dependency preserving decomposition? Where Fi is the set of FDs in F+ that include only attributes in
R i.
❑ Since ( F1 U F2 )+ = F+, it is a dependency preserving decomposition.
104
Question 4
Given R=(A, B, C, D), F={A→B, BC→D, D→A}
105
Question 4
Given R=(A, B, C, D), F={A→B, BC→D, D→A}
106
106
Question 4
Given R=(A, B, C, D), F={A→B, BC→D, D→A}
c) Is B→D in F+ ?
– No. Because B+ = {B}
d) Is D→BC in F+ ?
– No. Because D + ={ABD}
e) Is AC→D in F+ ?
– Yes. Because A→B and BC→D, we know that AC→D (pseudo-
transitivity)
107
107
Question 4
Given R=(A, B, C, D), F={A→B, BC→D, D→A}
• Lossless?
– R1∩R2=(B,C)
– (B,C)→R2
– Hence, it is a lossless decomposition.
109
Question 4
Given R=(A, B, C, D), F={A→B, BC→D, D→A}
• Is R in BCNF?
– No. A→B and D→A violate BCNF as neither A nor D is a super
key in R.
110
Question 4
Given R=(A, B, C, D), F={A→B, BC→D, D→A}
Step 1. Decompose R into two relations R1 and Step 2. Check if R1 and R2 are in BCNF. If not,
R2, and make R1 a BCNF. further decompose it using Step 1.
Look at A→B in F, make R1 as (A,B). In BCNF, every non-trivial FD forms a key! 111
Then R2 is (A,C,D).
111
Question 4
Given R=(A, B, C, D), F={A→B, BC→D, D→A}