0% found this document useful (0 votes)
46 views

Database Systems: Decomposition & Schema Refinement

The document discusses decomposition and lossless decomposition of relations in database normalization. It defines decomposition as replacing a relation with two or more relations such that each new relation contains attributes from the original relation and the original relation can be reconstructed by joining the new relations. Lossless decomposition is defined as a decomposition where the natural join of the new relations produces exactly the original relation, without any loss of information. The goal of decomposition is to eliminate redundancy while maintaining relational integrity through lossless decomposition.

Uploaded by

Rehman Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Database Systems: Decomposition & Schema Refinement

The document discusses decomposition and lossless decomposition of relations in database normalization. It defines decomposition as replacing a relation with two or more relations such that each new relation contains attributes from the original relation and the original relation can be reconstructed by joining the new relations. Lossless decomposition is defined as a decomposition where the natural join of the new relations produces exactly the original relation, without any loss of information. The goal of decomposition is to eliminate redundancy while maintaining relational integrity through lossless decomposition.

Uploaded by

Rehman Aziz
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Database Systems

Lecture 06
Decomposition & Schema Refinement

Chapter 7, Database System Concepts, Silberschatz, Korth, Sudarshan


Chapter 9, Database Systems; concepts, designs and applications, S.K.Singh

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)

If we union R1 and R2, we get R


R = R1 U R2
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
Decomposition

 Eliminates Redundancy
 To get back the original relation: Natural Join

7
Unnecessary Decomposition

 Join returns original relation: Fine


 No redundancy is removed and SID is stored twice: Unnecessary
8
Dependencies within relations

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

214-45-2398 Lance Smith Engineer Product

Note: Name is functionally dependent on SSN because an employee’s


name can be uniquely determined from their SSN. Name does not
determine SSN, because more than one employee can have the same
name..
Keys

 Whereas a key is a set of attributes that uniquely identifies


an entire tuple, a functional dependency allows us to
express constraints that uniquely identify the values of
certain attributes.

 However, a candidate key is always a determinant, but a


determinant doesn’t need to be a key.
Closure
 Let a relation R have some functional dependencies F
specified. The closure of F (usually written as F+) is
the set of all functional dependencies that may be
logically derived from F.
 Often F is the set of most obvious and important
functional dependencies and F+, the closure, is the set
of all the functional dependencies including F and
those that can be deduced from F.
 The closure is important and may, for example, be
needed in finding one or more candidate keys of the
relation.
Example
Student
SNo SNam CNo CName Addr Instr. Office
e
5425 Susan 102 Calc I …San P. B42
Ross Jose, Smith Room
CA 112
7845 Dave 541 Bio 10 ...San L. B24
Turco Diego Talip Room
, CA 210
SNo -> SName CNo -> CName Instr -> Office
SNo -> Addr CNo -> Instr
Functional Dependence
S# CITY P# QTY

S1 Khon Kaen P1 100


S1 Khon Kaen P2 100
S2 Saraburii P1 200
S2 Saraburii P2 200
S3 Saraburii P2 300
S4 Bangkok P2 400
S4 Bangkok P4 400
S4 Bangkok P5 400

S#,P# QTY QTY is functionally dependent on S#andP#

S# and P# are the determinant of QTY


Recap
Functional Dependence
 In a relation including attribute A and B, B is
functional dependent on A if, for every valid
occurrence, the value A determines the value B
 An occurrence can not be used to show that a
dependency is true, only that it is false
 A and B can be composite
 If B is ‘Functional Dependent on’ A, then A ‘is the
determinant of B’
 All fields are functionally dependent on the primary key –
or indeed any candidate key – be definition.
Decomposition Continued

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

a11 Canon 100 Canon

s20 Nikon 200 Nikon


a70 Canon 150 Canon
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


R
a11 100 Canon
s20 200 Nikon
a70 150 Canon
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
Lossy decomposition (more example)
T Employee Project Branch
Brown Mars L.A.
Green Jupiter San Jose
Green Venus San Jose
Hoskins Saturn San Jose
Hoskins Venus San Jose

Functional dependencies:

Employee Branch, Project Branch


Lossy decomposition

Decomposition of the previous relation


T1 T2

Employee Branch Project Branch


Mars L.A.
Brown L.A
Jupiter San Jose
Green San Jose
Saturn San Jose
Hoskins San Jose Venus San Jose
Lossy decomposition
After Natural Join Original Relation

Employee Project Branch Employee Project Branch


Brown Mars L.A. Brown Mars L.A.
Green Jupiter San Jose Green Jupiter San Jose
Green Venus San Jose Green Venus San Jose
Hoskins Saturn San Jose Hoskins Saturn San Jose
Hoskins Venus San Jose Hoskins Venus San Jose
Green Saturn San Jose
Hoskins Jupiter San Jose

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
XZ
4. Union: If X  Y and X  Z, then X  YZ
5. Decomposition: If X  YZ, then X  Y and
XZ
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

 Since branch-name branch-city assets, the augmentation rule


for FD implies that:
branch-name branch-name branch-city assets

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

Thus, this decomposition is Lossless decomposition


Conclusions
 Decompositions should always be lossless
Lossless decomposition ensure that the information in the
original relation can be accurately reconstructed based on
the information represented in the decomposed relations.
References
 Fundamentals of Database Systems Fourth Edition Elmasri,
Navathe
 Chapter 4, Database System Concepts Fourth Edition
Silberschatz, Korth, Sudarshan
 Chapter 9, Database Systems; concepts, designs and
applications, S.K.Singh
 Lossless Decomposition by Anannya Sengupta and Prof. Sin-
Min Lee (retrieved from : www.cs.sjsu.edu/~lee/cs157b/Lossless
%20Decomposition.ppt)

You might also like