decomposition

23
Decomposition

Upload: grazia

Post on 23-Feb-2016

28 views

Category:

Documents


0 download

DESCRIPTION

Decomposition. Undesirable Properties of Bad Design. Redundancy, resulting in waste of space and complicated updates (inconsistencies.) Inability to represent certain information – ex Null values. Loss of information. How to avoid ?. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Decomposition

Decomposition

Page 2: Decomposition

Undesirable Properties of Bad Design

Redundancy, resulting in waste of space and complicated updates (inconsistencies.)

Inability to represent certain information – ex Null values.

Loss of information.

Page 3: Decomposition

How to avoid ?

Properties of information repetition and null values suggest -- Decomposition of relation schema.

Properties of information loss -- Non-lossy-join decomposition.

Page 4: Decomposition

Decompositions

There are careless, “bad” decompositions. There are three desirable properties:

1. Lossless.2. Dependency preservation.3. Minimal redundancy.

Page 5: Decomposition

Definition of Decomposition

Let R be a relation schema A set of relation schemas { R1, R2,…, Rn } is a

decomposition of R if

R = R1 U R2 U …..U Rn each Ri is a subset of R ( for i = 1,2…,n)

Page 6: Decomposition

Example of Decomposition

For relation R(x,y,z) there can be 2 subsets:R1(x,z) and R2(y,z)

If we union R1 and R2, we get RR = R1 U R2

Page 7: Decomposition

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

Page 8: Decomposition

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

Page 9: Decomposition

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

Page 10: Decomposition

Example : Problem with DecompositionR1 U R2

Model Name Price Categorya11 100 Canona11 150 Canons20 200 Nikona70 100 Canona70 150 Canon

Model Name Price Category

a11 100 Canon

s20 200 Nikon

a70 150 Canon

R

Page 11: Decomposition

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

Page 12: Decomposition

Lossy decomposition (more example)

Employee Project Branch Brown Mars L.A.Green Jupiter San JoseGreen Venus San JoseHoskins Saturn San JoseHoskins Venus San Jose

T

Functional dependencies:

Employee Branch, Project Branch

Page 13: Decomposition

Lossy decomposition

Decomposition of the previous relation

Employee Branch

Brown L.A

Green San Jose

Hoskins San Jose

Project Branch

Mars L.A.

Jupiter San Jose

Saturn San Jose

Venus San Jose

T1 T2

Page 14: Decomposition

Lossy decomposition

Employee Project BranchBrown Mars L.A.Green Jupiter San JoseGreen Venus San JoseHoskins Saturn San JoseHoskins Venus San JoseGreen Saturn San JoseHoskins Jupiter San Jose

Employee Project BranchBrown Mars L.A.Green Jupiter San JoseGreen Venus San JoseHoskins Saturn San JoseHoskins Venus San Jose

After Natural Join Original Relation

After Natural Join, we get two extra tuples. Thus, there is loss of information.

Page 15: 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.

Page 16: Decomposition

Lossless DecompositionA decomposition is lossless if we can recover:

R(A, B, C)Decompose

R1(A, B) R2(A, C) RecoverR’(A, B, C)

Thus, R’ = R

Page 17: Decomposition

Lossless Decomposition PropertyR : relationF : set of functional dependencies on RX,Y : decomposition of RDecomposition is lossles if :

X ∩ Y X, that is: all attributes common to both X and Y functionally determine ALL the attributes in X OR

X ∩ Y Y, that is: all attributes common to both X and Y functionally determine ALL the attributes in Y

Page 18: Decomposition

Lossless Decomposition Property In other words, if X ∩ Y forms a superkey of

either X or Y, the decomposition of R is a lossless decomposition

Page 19: Decomposition

Armstrong’s Axioms

X, Y, Z are sets of attributes

1. Reflexivity: If X Y, then X Y 2. Augmentation: If X Y, then XZ YZ for any Z3. Transitivity: If X Y and Y Z, then

X Z4. Union: If X Y and X Z, then X YZ5. Decomposition: If X YZ, then X Y and

X Z

Page 20: Decomposition

Example : Lossless DecompositionGiven:

Lending-schema = (branch-name, branch-city, assets, customer-name, loan-number, amount)Required FD’s:branch-namebranch-city assetsloan-number amount branch-nameDecompose Lending-schema into two schemas:Branch-schema = (branch-name, branch-city, assets)Loan-info-schema = (branch-name, customer-name, loan-number, amount)

Page 21: Decomposition

Example : Lossless DecompositionShow that decomposition is Lossless Decomposition

Since branch-name branch-city assets, the augmentation rule for FD implies that:branch-namebranch-name branch-city assets

Since Branch-schema ∩ Loan-info-schema = {branch-name}

Thus, this decomposition is Lossless decomposition

Page 22: Decomposition

Conclusions

Decompositions should always be losslessLossless decomposition ensure that the information in the original relation can be accurately reconstructed based on the information represented in the decomposed relations.

Page 23: Decomposition

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.