Professional Documents
Culture Documents
Plugin Databases Logical Design
Plugin Databases Logical Design
• SP → C (given)
• SP → S (reflexivity)
• SP → SC (union of 1. and 2.)
• SP → PMG (transitivity of 3. & first FD above)
• SP → M (decomposition)
Closure of attributes
• We denote by X+ the set of all attributes
functionally determined by X
• X+ is called the closure of X
• To find whether Y is a superkey for relation R, we
see if Y+ contains all attributes of R
• To see if X → Y is true or not, just find X+ and
see if it includes all the attributes of Y
• X+ are all the values that follow uniquely once the
value of X is known (everything X maps onto
uniquely)
Finding X+
1. Let ans = X
2. For every FD Y → Z s.t. Y ⊆ ans, add Z
to ans
3. Repeat step 2 until no more attributes can
be added to ans
4. ans is now the closure of X
Example : finding attribute closure
SC → PMG SL → C CT → L TL → C SP → C
What is the closure of SL ?
start with ans = {SL}
using 2nd FD, ans = {SLC}
using 1st FD, ans = {SLCPMG}
no more attributes can be added so (SL)+ is SLCPMG
Is SL a superkey for R(SCPMGLT)? no, SL → T
Does SL → PG? yes, because PG are in (SL)+
Summary so far
• FDs tell us important constraints on the data
• FDs can be used to check if attributes form
a candidate key for a relation
• attribute closure is easy to compute
• to see if an FD X Y is true, find X+ and see
if it contains all of Y
• Next: FDs can also tell us if a relation
scheme is good or bad
Boyce-Codd Normal Form
A relation R is in BCNF if and only if, for every FD
X → Y that holds on R:
X → Y is trivial (i.e. Y ⊆ X)
or X is a superkey for R
While (1) and (2) above are always possible, (3) is not always
possible. For example, some BCNF decompositions
aren’t dependency preserving – see. e.g. that of R(CSP)
in the previous slide.
Lossless join decompositions
• If R is decomposed into R1 and R2 then this is a
lossless join decomposition if and only if the join
of R1 and R2 gives exactly the original tuples of R
• If it is a lossless join decomposition, then either
(R1 ∩ R2) → R1 or (R1 ∩ R2) → R2 i.e. the
common attributes are a key of one of the relations
• Otherwise, when we join up R1 and R2, we get
additional/extraneous/nonsense tuples!
• The BCNF/3NF decomposition algorithm always
gives a lossless join decomposition.
E.g. relation scheme decomposition
R (sno, sname, pno, pname, cost, selling, quantity)