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

1.8 Types of Decomposition and Dependency Preservation

Uploaded by

kirtick.mm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

1.8 Types of Decomposition and Dependency Preservation

Uploaded by

kirtick.mm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Decomposition in DBMS

Decomposition in DBMS
• The process of decomposition in DBMS helps us remove
redundancy, inconsistencies and anomalies from a
database when we divide the table into numerous tables.

• The term decomposition refers to the process in which


we break down a table in a database into various
elements or parts.
Decomposition is of two major types in DBMS:
•Lossless
•Lossy
Lossless Decomposition
• A decomposition is said to be lossless when it
is feasible to reconstruct the original relation R
using joins from the decomposed tables.
• Let us take ‘A’ as the Relational Schema,
having an instance of ‘a’. Consider that it is
decomposed into: A1, A2, A3, . . . . An; with
instance: a1, a2, a3, . . .. an, If a1 ⋈ a2 ⋈ a3 . . .
. ⋈ an, then it is known as ‘Lossless Join
Decomposition’.
Lossy Decomposition
• Whenever we decompose a relation into
multiple relational schemas, then the loss of
data/information is unavoidable whenever we
try to retrieve the original relation.
Properties of Decomposition

Decomposition must have the following properties:

1. Decomposition Must be Lossless


2. Dependency Preservation
3. Lack of Data Redundancy
1. Decomposition Must be Lossless

• Decomposition must always be lossless,


which means the information must never
get lost from a decomposed relation.
2. Dependency Preservation
• Dependency is a crucial constraint on a
database, and a minimum of one decomposed
table must satisfy every dependency.
• If {P → Q} holds, then two sets happen to be
dependent functionally.
3. Lack of Data Redundancy
• It is also commonly termed as a repetition of
data/information. When decomposition is
careless, it may cause issues with the overall
data in the database.
Examples – Lossless
Decomposition
• Apply Natural Join decomposition on the below two tables:
Cust_ID Cust_Name Cust_Age Cust_Location
C001 Monica 22 Texas
C002 Rachel 33 Toronto
C003 Phoebe 44 Minnesota

Sec_ID Cust_ID Sec_Name


Sec1 S001 Accounts
Sec2 S002 Marketing
Sec3 S003 Telecom
Examples – Lossless
Decomposition
• Lossless Decomposition:

Cust_ID Cust_Nam Cust_Age Cust_Location Sec_ID Sec_Name


e
S001 Monica 22 Texas Sec1 Accounts
S002 Rachel 33 Toronto Sec2 Marketing

S003 Phoebe 44 Minnesota Sec3 Telecom


Examples – Lossy Join
Decomposition
Relational Schema = A (X, Y, Z)
Decompositions,
A1 (X, Y)
A2 (X, Z) X Y Z
X1 Y1 Z1
X2 Y1 Z1
X1 Y2 Z2
X1 Y3 Z3
Examples – Lossy Join
Decomposition
Decompositions:
X Y X Z
X1 Y1 X1 Z1
X2 Y1 X2 Z1
X1 Y2 X1 Z2
X1 Y3 X1 Z3
Examples – Lossy Join
Decomposition
Now, if we want X Y Z
this
decomposition X1 Y1 Z1
to be lossy, then X1 Y1 Z2
A ⊂ A1 ⨝ A2
X2 Y1 Z1
Thus, A1 ⨝ A2
will be equal to X1 Y2 Z2
X1 Y2 Z1
X1 Y3 Z3
X1 Y3 Z1
1
4

Dependency Preservation
• Let Fi be the set of dependencies
F+ that includes only attributes in
Ri
– A decomposition is dependency
preserving, if (F1  F2  …  Fn)+ =
F+
– If it is not, then checking updates for
violation of functional dependencies
may require computing joins, which is
expensive
1
5

Example - Dependency
Preservation
• A Dependency preserving decomposition of a relation R is R1,
R2, R3...Rn concerning the set of Functional Dependencies FD
if,

• (FD1 ∪ FD2 ∪ ... ∪ FDn)+ = FD+ where,

• FD1, FD2, FD3…...FDn Sets of Functional dependencies of


relations R1, R2, R3 ...Rn.
• (FD1 U FD2 U FD3 U … U FDn)+ -> Closure of Union of all sets
of functional dependencies.
• FD+ -> Closure of set of functional dependency FD of R.
1
6

Example - Dependency
Preservation
• With FD (FD1) R is decomposed or divided into R1 and with
FD(FD2) into R2, then the possibility of three cases arise,

• FD1 ∪ FD2 = FD -> Decomposition is dependency preserving.


• FD1 ∪ FD2 is a subset of FD -> Not Dependency preserving.
• FD1 ∪ FD2 is a superset of FD -> This case is not possible.
1
7

Example - Dependency
Preservation
• Let suppose, a relation R (P, Q, R, S) with a set of Functional
Dependency FD = (PQ→R, R→S, S→P) is given. Into R1 (P, Q, R)
and R2(R, S), relation R (P, Q, R, S) is decomposed. Find out
whether the decomposition is dependency preserving or not.

Solution:

Decomposed relations of relation R (P, Q, R, S) are R1 (P, Q, R) and


R2 (R, S). To solve this problem, we need to first find the closure of
Functional Dependencies FD1 and FD2 of the relations R1 (P, Q, R)
and R2(R, S).

1) To find the closure of FD1, we have to consider all combinations of


(P, Q, R). i.e., we need to find out the closure of P, Q, R, PQ, QR, and
RP.
1
8

Example - Dependency
Preservation
closure (P) = {P} // Trivial
closure (Q) = {Q} // Trivial
closure (R) = {R, P, S} //but S can't be in closure as S is not
//present in R1 (P, Q, R).
= {R, P}
(R--> P // Removing R from right side as it is trivial
attribute)
closure (PQ) = {P, Q, R, S}
= {P, Q, R}
(PQ --> R // Removing PQ from right side as these are trivial
attributes)
closure (QR) = {Q, R, S, P}
= {P, Q, R}
1
9

Example - Dependency
Preservation
(QR --> P // Removing QR from right side as these are trivial attributes)
Closure (PR) = {P, R, S}
(PR --> S // Removing PR from right side as these are trivial attributes)
FD1 {R --> P, PQ --> R, QR --> P}.

2) Similarly FD2 {R--> S}

In the original Relation Dependency FD= {PQ→R, R→S, S→P}.

PQ --> R is present in FD1.


R --> S is present in FD2.
S --> P is not preserved.
2
0

Example - Dependency
Preservation
• From the given result, in FD1, PQ holds R (PQ --> R) and in FD2, R
holds S (R --> S). But, there is no follow up in Functional
Dependency S holds P (S --> P).

• FD1 U FD2 is a subset of FD.

• So as a consequence, given decomposition is not dependency


preserving.

You might also like