0% found this document useful (0 votes)
12 views21 pages

7.lossless & Lossy

The document discusses lossless join decomposition and dependency preserving decomposition in database normalization. It provides examples to show how to check if a relation decomposition is lossless and dependency preserving. It also contains practice problems and their solutions.

Uploaded by

shubhrajit.g2002
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)
12 views21 pages

7.lossless & Lossy

The document discusses lossless join decomposition and dependency preserving decomposition in database normalization. It provides examples to show how to check if a relation decomposition is lossless and dependency preserving. It also contains practice problems and their solutions.

Uploaded by

shubhrajit.g2002
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/ 21

1

Rupali's
DBMS
PRESENTED BY RUPALI CHOWDHURY
Rupali's
2
3
l This property guaranties that the extra or less tuple generation problem
doesn't occur after decomposition.

Rupali's
l It is mandatory property must always holds good.
l If a relation R is decomposed into two relations R1 and R2,then it will be
lossless iff

I. attr(R1) attr(R2)=attr( R)

ii. attr(R1) attr(R2)≠Φ [There should be common attribute in two table]

iii. attr(R1) attr(R2)--------->attr(R1)


or
attr(R1) attr(R2)--------->attr(R2)
4
i. attribute should not be lossed. Data loss or data gain
R
R1xR2

Rupali's
A B C D
1 a p x A B C D
Spurious tuple
2 b q y 1 a p x
R1 R2 1 a q y
A B
1 a
D 2 b p x
x
2 b 2 b q y
y
iii) Common attribute should be key either in first or second
ii )There should be common attribute in two table. table.
R Common attribute value should be unique or distinct
A B C D Common attribute should be candidate key
1 a p x R
2 b q y A B C
1 a p
2 b q
R1 R2 3 a r
A B R1
C D R2
1 a A B
p x B C
2 b 1 a
q y a p
2 b
b q
3 a
a r
Practice problem of lossless join decomposition not 5
additive join property Which option is correct?
1) R1(AB)R2(CD)

Rupali's
A B C D E
a 122 1 p w 2) R1(ABC),R2(DE)
b 234 2 q x 3) R1(ABC),R2(CDE)
a 568 1 r y 4) R1(ABCD),R2(ACDE)
c 347 3 s z
5) R1(ABCD),R2(DE)
6) R1(ABC),R2(BCD),R3(DE)
Ans:
1. R1(ABC),R2(CD): E attribute is missing,not lossless

2. R1(ABC),R2(DE):No common attribute,not lossless

3. R1(ABC),R2(CDE):Common attribute value is not distinct,not lossless,redundancy will occur

4. R1(ABCD),R2(ACDE):ACD common attribute for two tables,& by combining both we get distinct values,So lossless

5. R1(ABCD),R2(DE):D is distinct ,so lossless

6. R1(ABC),R2(BCD),R3(DE):R1(ABC),R2(BCD) B common & distinct


R12(ABCD) R3(DE) D common & distinct ,So lossless
EXAMPLE2: Which option is correct?
R(VWXYZ) 1. R1(VWX) R2(XYZ) 6
Z-->Y 2. R1(VW) R2(YZ)
Y-->Z 3. R1(VWX) R2(YZ)
X-->YV 4. R1(VW)R2(WXYZ)

Rupali's
VW-->X

Ans:
1. R1(VWX) R2(XYZ) ---> R1(VWX)
X+=XV
I) All attributes are covered
i) X common R2(XYZ)
ii) X is candidate key so decomposition is lossless X+=XYZ here X candidate key

2. R1(VW) R2(YZ)
I. All attributes are not covered,decomposition is lossy
3. R1(VWX) R2(YZ)
I. All attributes are covered
II. No common attributes So, decomposition is lossy
4. R1(VW)R2(WXYZ)
I. All attributes are covered
II. W common
III. From only W there is no dependency So, we can’t guarantee that the decomposition is lossless.W is not
candidate key
Dependency preserving decomposition 7
If a table R having FD set F is decomposed into two tables R1 & R2 having FD set F1&F2 then

R(F)

Rupali's
R1(F1) R2(F2)

R(F1 F2)
EXAMPLE1:
R(ABC) Where FDs are
A--->B
B---->C
C---->A check whether the decomposition is dependency preserving or not
Ans:

So,the decomposition is dependency preserving.


Example2:
R(ABCD) Where FDs are 8
AB--->CD
A---->A

Rupali's
check whether the decomposition is dependency preserving or not
Ans:

So,Decomposition is lossless (D is candidate key) but not dependency preserving


(AB--->CD dependency loss)
9

Rupali's
Given R(A,B,C,D,E,G) with the functional dependencies
F {AD E,B D,E G} are decomposed into R1(A,B),R2(B,C),
R3(A,B,D,E) ,R4(E,G)check wheather the decomposition is dependency preserving and
loss less or not.
To check whether the decomposition is lossless or not
Relations are: FDs are: A B C D E G Repeat the process
AD E R1 again
R1(A,B)
B D
R2(B,C) R2
E G
R3(A,B,D,E)
R3
R4(E,G)
R4

We can't find any rows containing all 'α's.So this decomposition is lossy.
10

Rupali's
Given R(A,B,C,D,E,G) with the functional dependencies
F {AB C,AC B,AD E,B D,BC A ,E G} are decomposed into
R1(A,B),R2(B,C), R3(A,B,D,E) ,R4(E,G)check wheather the decomposition is dependency
preserving and loss less or not.
To check whether the decomposition is lossless or not
Relations are: FDs are:
AB C
R1(A,B)
AC B
R2(B,C)
AD E
R3(A,B,D,E)
B D
R4(E,G)
BC A
E G

We can't find any rows containing all 'α's.So this decomposition is lossy.
11
Supplier Part Project
no. no. no. ᴫSP ᴫPJ ᴫJS

Rupali's
S# P# J# S# P# P# J# J# S#
S1 P1 J2 S1 P1 P1 J2 J2 S1
S1 P2 J1 S1 P2 P2 J1 J1 S1
S2 P1 J1 S2 P1 P1 J1 J1 S2
S1 P1 J1
SP PJ After joining the decomposed
SPJ relation we either gain/loose tuple
CandidateKEY(S#,P#,j#) S# P# J#
S1 P1 J2
S1 P1 J1
S1 P2 J1
S2 P1 J2
Spurious tuple
S2 P1 J1
12
Supplier Part Project
no. no. no. ᴫSP ᴫPJ ᴫJS

Rupali's
S# P# J# S# P# P# J# J# S#
S1 P1 J2 S1 P1 P1 J2 J2 S1
S1 P2 J1 S1 P2 P2 J1 J1 S1
S2 P1 J1 S2 P1 P1 J1 J1 S2
S1 P1 J1
(SP PJ) JS)
SPJ Let R be a relation & Let A,B.....Z be arbitrary
CandidateKEY(S#,P#,j#) S# P# J# subsets of the set of attributes of R
S1 P1 J2 Then we say R satisfies join dependency
(JD).This is denoted by*(A,B.....Z) iff R is equal to
S1 P1 J1
the join of its projections on (A,B,....,Z)
S1 P2 J1 SPJ=*(SP,PJ,JS)has a join dependency(JD)
S2 P1 J1 There is no join dependency in SP,PJ,JS
individually
13

Rupali's
14

A relation is in 5NF if it is in 4NF and not having any join dependency and joining should

Rupali's
be lossless.
Here the candidate key has to be entirely present in each of its projection
A relation that has a join dependency can not be divided into two (or more)relations such
that the resulting tables can be concerned to form original table.

ᴫSP ᴫPJ ᴫJS


S# P# P# J# J# S#
S1 P1 P1 J2 J2 S1
S1 P2 P2 J1 J1 S1
S2 P1 P1 J1 J1 S2

Each of SP,PJ,JS are in 5 NF because they are in join dependency at all.


15

Rupali's
16

Rupali's
which specifies the possible values of
some attribute.
E.g. The only colors of cars are blue, white, red, grey.
E.g. The age of a person is between 0 and 150.
(2) Key constraint - which specifies keys of some relation.
17

Rupali's
A relation will in DKNF if and only if every content of the
relation is a logical consequence of domain constraints or
key constraints

In 6 NF ,it is intended to decompose relation variables to


irreducible components
18

Rupali's
Let Acct (acct#, balance) with acct# balance and a general constraint:
“ if the first digit of an account is 9,
then the balance of the account is ≥ 2500.”
• Relation Acct is not in DKNF
• To create a DKNF design, we split the relation horizontally into 2 relations:

Regular_Acct (acct#, balance)


Key = {acct#}
Domain constraint: the first digit of acct# is not 9.

Special_Acct (acct#, balance)


Key = {acct#}
Domain constraints:
(1) t he first digit of acct# is 9, and.
(2) balance ≥ 2500.
19

Rupali's
1.Given R(A,B,C,D,E) with the functional dependencies F{AB CD,A E,C D}
are decomposed into R1(A,B,C),R2(B,C,D) and R3(C,D,E) check whether the
decomposition is dependency preserving and loss less or not.

2.
20

Rupali's
21

Rupali's

You might also like