Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

7.1 Binary Decomposition

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Decomposition

1
Binary Decomposition - 1

Binary Decomposition can be applied to:


Decompose a non-BCNF relation into a
collection of BCNF relations
Decompose a non-3NF relation into a
collection of 3NF relations

2
Binary Decomposition - 2

Basic Steps of Binary Decomposition:


Suppose X A F is a FD violating the BCNF
(resp. 3NF) requirement, where X R and A
R
Decompose R into XA and R A
If either XA or R A is not in BCNF (resp.
3NF), decompose it further

3
Binary Decomposition - 3

If R w.r.t. F is not in BCNF, we can always


obtain a lossless-join decomposition of R into a
collection of BCNF relations. However, it may
not always be dependency preserving
If R w.r.t. F is not in 3NF, we can always obtain
a lossless-join decomposition and dependency
preserving of R into a collection of 3NF
relations. How?

4
Binary Decomposition - 4

Let R = { R1, R2, . . . Rn} be the result of binary


decomposition. This is always lossless-join, but may not
preserve the FDs need to fix it
Identify the set Lost of FDs in F that are lost (i.e., not
preserved)
For each FD X A in Lost, create a relation schema
XA and add it to R
Refinement step: if there are several FDs with the
same LHS, e.g., X A1, X A2, . . . , X Ak, we
replace these k FDs with a single FD X A1Ak
and create just one relation with schema XA1Ak
5
Synthesis Approach

Synthesis Approach is applicable for 3NF


decomposition only
Consider relation schema <R, F>
The synthesis approach:
Get a canonical cover FC of F
For each FD X A in FC, add schema XA to R
If the decomposition R is not lossless, need to fix
it by adding to R an extra relation schema
containing just those attributes that form any key
of R 6
Review: Decomposition into 3NF

Binary Decomposition:
Lossless-join
May not be dependency preserving. If so, then
add extra relations XA, one for each FD X A
we lost
Synthesis Approach
Dependency preservation
May not be lossless-join. If so, we need to add to
R one extra relation schema that includes the
attributes that form any key of R
7
Question #1
Consider R = {A, B, C, D, E, F, G, H} with a set of
FDs
F = {CDA, ECH, GHBAB, CD, EGA,
HB, BECD, ECB}
The candidate keys are: {BEFG, CEFG, EFGH}
Is R w.r.t. F in 3NF? If not, decompose it into
relations in 3NF using:
1. Binary Decomposition
2. Synthesis Approach

8
To Check Lossless Join - 1
Suppose relation R{A1 , . . . , Ak} is decomposed
into R1,. . . , Rn
To determine if this decomposition is lossless, we
use a table,
L[ 1 n ] [ 1 . . . k ]

Initializing the table:

for each relation Ri do


for each attribute Aj do
if Aj is an attribute in Ri
then L [ i ][ j ] aAj
else L [ i ][ j ] biAj 9
To Check Lossless Join - 2

repeat
for each FD X Y in F do:
if rows i and j such that L [ i ] == L [ j ], for each attribute
in X,
then for column t corresponding to an attribute At in Y do:
if L [ i ][ t ] == aAt
then L [ j ][ t ] aAt
else if L [ j ][ t ] == aAt
then L [ i ][ t ] aAt
else L [ j ][ t ] L [ i ][ t ]
until no change

The decomposition is lossless if L contains a row of all as.


10
Question #2
Assume R(A, B, C, D, E, F, G) with the set of FDs
F={CAD, EG, FGA, EFA, GB, BEC}
is decomposed into the following relations. Check if
this decomposition is lossless join.
R1 = {A, C, D}
R2 = {E, C, G}
R3 = {A, F, G}
R4 = {A, E, F}
R5 = {B, G}
R6 = {B, C, E}

11

You might also like