7.lossless & Lossy
7.lossless & Lossy
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)
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
4. R1(ABCD),R2(ACDE):ACD common attribute for two tables,& by combining both we get distinct values,So lossless
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:
Rupali's
check whether the decomposition is dependency preserving or not
Ans:
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.
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
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:
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