Sie sind auf Seite 1von 25

Goal of Decomposition

Eliminate redundancy by decomposing a relation


into several relations in a higher normal form.
It is important to check that a decomposition
does not lead to bad design
There are three desirable properties:
1. Lossless.
2. Dependency preservation.
3. Minimal redundancy.

Problem with Decomposition
Given instances of the decomposed relations,
we may not be able to reconstruct the
corresponding instance of the original
relation information loss
Example : Problem with Decomposition

Model Name Price Category
a11 100 Canon
s20 200 Nikon
a70 150 Canon
R
Model Name Category
a11 Canon
s20 Nikon
a70 Canon
Price Category
100 Canon
200 Nikon
150 Canon
R1 R2
Example : Problem with Decomposition
R1 U R2


Model Name Price Category
a11 100 Canon
a11 150 Canon
s20 200 Nikon
a70 100 Canon
a70 150 Canon
Model Name Price Category
a11 100 Canon
s20 200 Nikon
a70 150 Canon
R
Lossy decomposition
In previous example, additional tuples are
obtained along with original tuples
Although there are more tuples, this leads to
less information
Due to the loss of information, decomposition
for previous example is called lossy
decomposition or lossy-join decomposition

Example of Relation Decomposition
Lossless Decomposition
A decomposition {R1, R2,, Rn} of a relation R is
called a lossless decomposition for R if the
natural join of R1, R2,, Rn produces exactly the
relation R.

Definition:
Let { R1, R2 } be a decomposition of R (R1 U
R2 = R); the decomposition is lossless if for
every legal instance r of R:
r = R1(r) |X| R2(r)

Lossless Decomposition
A decomposition is lossless if we can recover:

R(A, B, C)
Decompose
R1(A, B) R2(A, C)
Recover
R(A, B, C)

Thus, R = R

Lossless Check Example 1:
Consider five attributes: ABCDE
Three relations: ABC, AD, BDE
FDs: A ->BD, B ->E

A B C D E
ABC a1 a2 a3 b14 b15
AD a1 b22 b23 a4 b25
BDE b21 a2 b33 a4 a5
Lossless Check Example





Lossless Check Example
Example 2:
R1 (A1, A2, A3, A5)
R2 (A1, A3, A4)
R3 (A4, A5)
FD1: A1 A3 A5
FD2: A5 A1 A4
FD3: A3 A4 A2

A1 A2 A3 A4 A5
R1 a(1) a(2) a(3) b(1,4) a(5)
R2 a(1) b(2,2) a(3) a(4) b(2,5)
R3 b(3,1) b(3,2) b(3,3) a(4) a(5)
Example (cont)
By FD1: A1 A3 A5

A1 A2 A3 A4 A5
R1 a(1) a(2) a(3) b(1,4) a(5)
R2 a(1) b(2,2) a(3) a(4) b(2,5)
R3 b(3,1) b(3,2) b(3,3) a(4) a(5)
Example (cont)
By FD1: A1 A3 A5
we have a new result table
A1 A2 A3 A4 A5
R1 a(1) a(2) a(3) b(1,4) a(5)
R2 a(1) b(2,2) a(3) a(4) a(5)
R3 b(3,1) b(3,2) b(3,3) a(4) a(5)

Example (cont)
By FD2: A5 A1 A4

A1 A2 A3 A4 A5
R1 a(1) a(2) a(3) b(1,4) a(5)
R2 a(1) b(2,2) a(3) a(4) a(5)
R3 b(3,1) b(3,2) b(3,3) a(4) a(5)
Example (cont)
By FD2: A5 A1 A4
we have a new result table
A1 A2 A3 A4 A5
R1 a(1) a(2) a(3) a(4) a(5)
R2 a(1) b(2,2) a(3) a(4) a(5)
R3 a(1) b(3,2) b(3,3) a(4) a(5)
Example (cont)
Why do we preserve the dependency?
We would like to check easily that updates to
the database do not result in illegal relations
being created.
It would be nice if our design allowed us to
check updates without having to compute
natural joins.
Dependency Preservation Decomposition
Definition: Each FD specified in F either appears directly in
one of the relations in the decomposition, or be inferred from
FDs that appear in some relation.

Test of Dependency Preservation
If a decomposition is not dependency-preserving, some
dependency is lost in the decomposition.
One way to verify that a dependency is not lost is to take
joins of two or more relations in the decomposition to get
a relation that contains all of the attributes in the
dependency under consideration and then check that the
dependency holds on the result of the joins.


Test of Dependency Preservation II
Find F - F', the functional dependencies not
checkable in one relation.
See whether this set is obtainable from F' by
using Armstrong's Axioms.
This should take a great deal less work, as we
have (usually) just a few functional
dependencies to work on.
Dependency Preserving Example
Consider relation ABCD, with FDs :
A ->B, B ->C, C ->D
Decompose into two relations: ABC and CD.
ABC supports the FDs A->B, B->C.
CD supports the FD C->D.
All the original dependencies are preserved.

Non-Dependency Preserving Example
Consider relation ABCD, with FDs:
A ->B, B ->C, C->D
Decompose into two relations: ACD and BC.
ACD supports the FD B ->C and implied FD A ->C.
BC supports the FD B->C.
However, no relation supports A ->B.
So the dependency is not preserved.


Minimal Redundancy
In order to achieve the lack of redundancy, we
do some decomposition which is represented
by several normal forms.

Conclusion
Decompositions should always be lossless.
Decompositions should be dependency
preserving whenever possible.
We have to perform the normal decomposition
to make sure we get rid of the minimal
redundant information.

Das könnte Ihnen auch gefallen