Database Systems: Decomposition & Schema Refinement
Database Systems: Decomposition & Schema Refinement
Lecture 06
Decomposition & Schema Refinement
1
Goals of Normalization &
Decomposition
Decide whether a particular relation R is in “good” form.
In the case that a relation R is not in “good” form,
decompose it into a set of relations {R1, R2, ..., Rn} such
that
Each relation is in good form
The decomposition is a lossless-join decomposition
2
Decomposition
Suppose that relation R contains attributes A1 ... An. A
decomposition of R consists of replacing R by two or
more relations such that:
Each new relation scheme contains a subset of the attributes of
R (and no attributes that do not appear in R), and
Every attribute of R appears as an attribute of one of the new
relations.
3
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)
Example of Decomposition
For relation R(x,y,z) there can be 2 subsets:
R1(x,z) and R2(y,z)
Eliminates Redundancy
To get back the original relation: Natural Join
7
Unnecessary Decomposition
Functional Dependency
Definition
A functional dependency is defined as a constraint
between two sets of attributes in a relation from a
database.
Given a relation R, a set of attributes X in R is said to
functionally determine another attribute Y, also in R,
(written X → Y) if and only if each X value is associated
with at most one Y value.
In other words….
X is the determinant set and Y is the dependent attribute.
Thus, given a tuple and the values of the attributes in X,
one can determine the corresponding value of the Y
attribute.
Example
Employee
SSN Name JobType DeptName
557-78-6587 Lance Smith Accountant Salary
Lossy Decomposition
& Lossless 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
Example : Problem with Decomposition
R
Model Name Price Category
a11 100 Canon
s20 200 Nikon
a70 150 Canon
R1 R2
Model Name Category Price Category
Functional dependencies:
After Natural Join, we get two extra tuples. Thus, there is loss of information.
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.
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 Decomposition Property
R : relation
F : set of functional dependencies on R
X,Y : decomposition of R
Decomposition 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
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
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 Z
3. Transitivity: If X Y and Y Z, then
XZ
4. Union: If X Y and X Z, then X YZ
5. Decomposition: If X YZ, then X Y and
XZ
Example : Lossless Decomposition
Given:
Lending-schema = (branch-name, branch-city, assets,
customer-name, loan-number, amount)
Required FD’s:
branch-name branch-city assets
loan-number amount branch-name
Decompose Lending-schema into two schemas:
Branch-schema = (branch-name, branch-city, assets)
Loan-info-schema = (branch-name, customer-name, loan-
number, amount)
Example : Lossless Decomposition
Show that decomposition is Lossless Decomposition