DBMS Chap 3
DBMS Chap 3
DBMS Chap 3
R1 ⋈ R2 ⋈ R3 ……. ⋈ Rn = R
Example-
1 2 1
2 5 3
3 3 3
R( A , B , C )
Consider this relation is decomposed into two sub relations R 1( A , B ) and R2( B , C )-
A B
1 2
2 5
3 3
R1( A , B )
B C
2 1
5 3
3 3
R2( B , C )
Now, if we perform the natural join ( ⋈ ) of the sub relations R1 and R2 , we get-
A B C
1 2 1
2 5 3
3 3 3
R1 ⋈ R2 ⋈ R3 ……. ⋈ Rn ⊃ R
Example-
A B C
1 2 1
2 5 3
3 3 3
R( A , B , C )
Consider this relation is decomposed into two sub relations as R 1( A , C ) and R2( B , C )-
A C
1 1
2 3
3 3
R1( A , B )
B C
2 1
5 3
3 3
R2( B , C )
Now, let us check whether this decomposition is lossy or not.
For lossy decomposition, we must have-
R1 ⋈ R2 ⊃ R
Now, if we perform the natural join ( ⋈ ) of the sub relations R1 and R2 we get-
A B C
1 2 1
2 5 3
2 3 3
3 5 3
3 3 3
This relation is not same as the original relation R and contains some extraneous tuples.
Clearly, R1 ⋈ R2 ⊃ R.
Thus, we conclude that the above decomposition is lossy join decomposition.
NOTE-
Condition-01:
Union of both the sub relations must contain all the attributes that are present in the original
relation R.
Thus,
R1 ∪ R2 = R
Condition-02:
R1 ∩ R2 ≠ ∅
Condition-03:
Intersection of both the sub relations must be a super key of either R 1 or R2 or both.
Thus,
R1 ∩ R2 = Super key of R1 or R2
Problem-01:
Solution-
Condition-01:
According to condition-01, union of both the sub relations must contain all the attributes of
relation R.
So, we have-
R1 ( A , B ) ∪ R2 ( C , D )
=R(A,B,C,D)
Clearly, union of the sub relations contain all the attributes of relation R.
Thus, condition-01 satisfies.
Condition-02:
According to condition-02, intersection of both the sub relations must not be null.
So, we have-
R1 ( A , B ) ∩ R2 ( C , D )
=Φ
Clearly, intersection of the sub relations is null.
So, condition-02 fails.
Thus, we conclude that the decomposition is lossy.
Problem-02:
Solution-
Strategy to Solve
When a given relation is decomposed into more than two sub relations, then-
Consider any one possible ways in which the relation might have been decomposed into those
sub relations.
First, divide the given relation into two sub relations.
Then, divide the sub relations according to the sub relations given in the question.
As a thumb rule, remember-
Any relation can be decomposed only into two sub relations at a time.
Consider the original relation R was decomposed into the given sub relations as shown-
Condition-01:
According to condition-01, union of both the sub relations must contain all the attributes of
relation R.
So, we have-
R‘ ( A , B , C ) ∪ R3 ( B , D )
=R(A,B,C,D)
Clearly, union of the sub relations contain all the attributes of relation R.
Thus, condition-01 satisfies.
Condition-02:
According to condition-02, intersection of both the sub relations must not be null.
So, we have-
R‘ ( A , B , C ) ∩ R 3 ( B , D )
=B
Clearly, intersection of the sub relations is not null.
Thus, condition-02 satisfies.
Condition-03:
According to condition-03, intersection of both the sub relations must be the super key of
one of the two sub relations or both.
So, we have-
R‘ ( A , B , C ) ∩ R 3 ( B , D )
=B
Now, the closure of attribute B is-
B+ = { B , C , D }
Now, we see-
Attribute ‘B’ can not determine attribute ‘A’ of sub relation R’.
Thus, it is not a super key of the sub relation R’.
Attribute ‘B’ can determine all the attributes of sub relation R3.
Thus, it is a super key of the sub relation R3.
Clearly, intersection of the sub relations is a super key of one of the sub relations.
So, condition-03 satisfies.
Thus, we conclude that the decomposition is lossless.
Condition-01:
According to condition-01, union of both the sub relations must contain all the attributes of
relation R’.
So, we have-
R1 ( A , B ) ∪ R2 ( B , C )
= R’ ( A , B , C )
Clearly, union of the sub relations contain all the attributes of relation R’.
Thus, condition-01 satisfies.
Condition-02:
According to condition-02, intersection of both the sub relations must not be null.
So, we have-
R1 ( A , B ) ∩ R 2 ( B , C )
=B
Clearly, intersection of the sub relations is not null.
Thus, condition-02 satisfies.
Condition-03:
According to condition-03, intersection of both the sub relations must be the super key of
one of the two sub relations or both.
So, we have-
R1 ( A , B ) ∩ R 2 ( B , C )
=B
Now, the closure of attribute B is-
B+ = { B , C , D }
Now, we see-
Attribute ‘B’ can not determine attribute ‘A’ of sub relation R1.
Thus, it is not a super key of the sub relation R1.
Attribute ‘B’ can determine all the attributes of sub relation R2.
Thus, it is a super key of the sub relation R2.
Clearly, intersection of the sub relations is a super key of one of the sub relations.
So, condition-03 satisfies.
Thus, we conclude that the decomposition is lossless.
Conclusion-
Overall decomposition of relation R into sub relations R1, R2 and R3 is lossless.