550 Lecture15
550 Lecture15
Properties of Decompositions
Decomposition of a Relation
Schema
• A decomposition of R consists of replacing R by
two or more relations such that:
– Each new relation schema contains a subset of the
attributes of R, and
– Every attribute of R appears as an attribute of one or
more new relations
• Store instances of the relation schemas produced
by the decomposition, instead of instances of R
• Decompositions should be used only when
needed
Decomposition Example
• Consider a relation obtained from Hourly_Emps:
– Hourly_Emps (ssn, name, lot, rating, hrly_wages, hrs_worked)
– Denote this relation schema by listing the attributes: SNLRWH
– SNLRWH has FDs: S ® SNLRWH and R ® W
– R ® W causes violation of 3NF
– Create a relation RW to store the associations and remove W
from the main schema (decompose SNLRWH into SNLRH and
RW)
• If we just store the projections of SNLRWH tuples onto
SNLRH and RW, are there any potential problems that we
should be aware of?
Problems with Decompositions
• Three potential problems:
1. Some queries become more expensive
• e.g., How much did sailor Joe earn? (salary = W*H)
2. Given instances of the decomposed relations, we
may not be able to reconstruct the corresponding
instance of the original relation!
3. Checking some dependencies may require joining the
instances of the decomposed relations
• Tradeoff: must consider these issues vs.
redundancy
Problem 2: Example
A B
1 2
A B C 4 5
1 2 3 7 2
4 5 6
B C
7 2 8
2 3
5 6
2 8
A B C
1 2 3
4 5 6
7 2 8
1 2 8
7 2 3
Lossless Join Decomposition
• Decomposition of R into X and Y has the
lossless-join property w.r.t. a set of FDs F if
for every instance r of R that satisfies F:
p X (r ) !" p Y (r ) = r
• It is always true that r Í p X (r ) !" p Y (r ). If the
other direction holds, the decomposition is
lossless-join
• Definition extends to decomposition into 3
or more relations
Lossless Join Decomposition (Cont.)
A minimal cover is
{BH ® C, A ® D, C ® E, F ® A, E ® F}
Exercise
• Find a minimal cover for {B ®A, D ®A, AB ®D}
• Find a minimal cover for {A ® B, ABCD ®E, EF
®G, EF ®H, ACDF ®EG}