Slides attached here describes mainly Functional dependencies in database management system, how to find closure set of functional dependencies and in last how decomposition is done in any database tables
2. Functional dependency:
• A dependency occurs in a database when information stored in
the same database table uniquely determines other information
stored in the same table.
or
• You can also describe this as a relationship where knowing the
value of one attribute is enough to tell you the value of another
attribute in the same table.
3. Definition:
Functional dependency is a relationship that exists
when one attribute uniquely determines another attribute.
• It is represented by an arrow () sign.
•Example:
Acc_no Cus_name Balance address
A1 Rahul 60000 veraval
A2 Meet 78000 Mehsana
A3 Prashant 65000 surat
•if we know the value of account no, we can obtain cus_name,address,
balance etc.
•By this, we can say that address,cus_name and balance is functionally
dependent on account no.
4. Set of rules to define functional dependency
1. Reflexivity rule:
if Y ⊆ X , then X Y
x y
Determinant Dependent
Read as…..
x holds y (from left to right)
or
y is dependent on x (from right to left)
Basic terminolog
5. 2. Augmentation rule :
if x y, then xz yz for any z.
where , z is a set of attributes.
3. Transitivity rule :
if x y and y z ,then x z.
4. Union rule :
if x y and x z, then x yz.
5. Decomposition rule :
if x yz,then x y and x z.
6. 6. Pseudotransitivity rule :
if x y and wy z,then xw z.
7. Composition rule :
if x y and w z then x,w y,z.
8. Self-determination rule :
x x
7. Types of functional dependencies:
1. Full functional dependency :
In a relation, the attribute B is
fully functionally dependent on A, if B is functionally dependent
on A but not on any proper subset of A.
• If we remove one of the attribute from the given relation then
dependency does not exist in fully functional dependency.
•Example :
{roll_no, dept_name} SPI
8. 2.Partial functional dependency :
In a relationship , the attribute B is
partially functionally dependent on A,if B is functionally
dependent on A as well as on any proper subset of A.
• if there is some attributes that can be remove from A and
then still the dependency holds it is known as partial
dependency.
•Example:
{enrollment_no,dept_name}
SPI
9. 3. Transitive functional dependency:
in a relation, if attribute
A B and B C then C is transitively dependent on A via B.
(provided that A is not functionally dependent on B and C)
•Example:
1. if , {staff_id} {staff_name} &
{staff_name} {staff_address}
then , {staff_id} {staff_address}
2. if , {Book} {Author}
{Author} {Author_nationality}
then, {book} {Author_nationality}
10. 4. Trivial functional dependency:
In a relationship, if attribute
Y is a subset of attribute X then the dependency is known as
trivial functional dependency.
•Example:
x y where y ⊆ x
{roll_no, dept_name} roll_no
11. 5. Non-trivial functional dependency:
in a relationship, if attribute Y
is not a subset of attribute X then it is known as non-trivial
dependency.
• Example:
x y where y ⊈ x
{roll_no, dept_name} student_name
12. Redundant functional dependency:
A functional dependency
In the set is said to be redundant if it can be derived from the
other functional dependency in the set.
13. Algorithm to find redundant functional dependency:
Input:
let F be a set of FDs for relation R.
let f: AB is a FD to be examined for redundancy.
Step 1 : F’= F - f # find out new set of FDs by
removing f from F.
Step 2 : T = A # set T equals to determinant of
A B
14. Step 3 : for each FD X Y in F’ do
if….. X ⊆ T then, # If X is contained in T
T=T ⋃ Y # Add Y to T.
end if
Step 4 : if…… B ⊆ T then, # If B is contained in T
f:AB is redundant # Given functional dependency.
end if.
Output :
decision whether given functional dependency is redundan
or not.
15. Example : suppose a relation R is given with attributes A,B,C,D
& E also set of FDs is given as follow:
F={A B, C D, BD E, AC E}
(I) Find out whether functional dependency f:AC E is redundant
or not?
(II) Find out whether functional dependency f:BD E is redundant
or not?
Solution (I): (for f:AC E).....
step 1: F’={AB,CD,BDE} # F’=F-f
step 2: T=AC # Set T= determinant of
AC E.
16. Step 3: T=AC+B = ACB # AB is in F’ and A ⊆ T.
T=ACB+D = ACBD # C D is in F’ and C ⊆ T.
T=ACBD+E = ACBDE # BD E is in F’ and BD ⊆ T.
Step 4: E ⊆ T.
Hence, f: ACE is redundant.
17. Solution (II): (for f:BD E)……
Step 1 : F’={AB ,CD ,ACE} # F’=F-f
Step 2 : T=BD # Set T=determinant
of BDE.
Step 3 : Nothing can be added to set T.
Hence, f: BDE is not redundant .
18. Closure set of functional dependency :
A closure set of a functional dependency is a set
of
all possible functional dependency that can be derived from a
given set of functional dependencies.
• it is also known as complete set of functional dependencies.
•If F is used to denote the set of FDs for relation R then closure
set of FDs implied by F, it is denoted by F+ .
19. Algorithm to find closure set of FD:
• Given a set of attributes A, define the closure of A for F as
the set of attributes that are functionally determined by A
under F (find A+ ) .
result = A
while (changes to result) do..
for each XY in F do…
begin
if ….X ⊆ result….then,
result=result ⋃ Y
end
20. Example to calculate the closure set of FD:
Example 1.Given the following result R={A,B,C}.A set of FD is as
follow:
AB
BC
find out closure of A,B and C? (find A+ ,B+ and C+ )
Solution : (i) A+ = A # A+ = A
= AB # A ⊆ A+ so B ⋃ A+
= ABC # B ⊆ A+ so C ⋃ A+
(ii) B+ = B # B+ =B
= BC #B ⊆ B+ so C ⋃ B+
(iii) C+ = C #C+ =C
21. Example 2 : Given the following result R={A,B,C,D}.A set of FD is
as follow:
AB, BC,ABD
find closure for A and AB.
Solution : A+ = A #A+ = A
= AB #A ⊆ A+ so B ⋃ A+
= ABC #B ⊆ A+ so C ⋃ A+
= ABCD #AB ⊆ A+ so D ⋃ A+
(AB)+ =AB # (AB)+ = AB
=ABD # AB ⊆ (AB)+ so D ⋃ (AB)+
=ABCD # B ⊆ (AB)+ so C ⋃ (AB)+
22. Decomposition :
The process of breaking down the given relatio
into two or more relations is known as decomposition.
• Here relation R is replaced by another relation in such a way that…
1. Each new relation contains a subset of the attributes of R
and
2. Together, they all include all tuples and attributes of R.
• example:
R: Account(a_no,balance,B_name,B_city)
R1: Account(a_no,balance,b_name)
R2: Branch(b_name,b_city)
23. •There are two types of decomposition:
1. lossy decomposition
2. lossless decomposition
1.lossy decomposition:
The decomposition of R into R1 and R2
is lossy when the joint of R1 and R2 does not give the same
relation as in R.
2.Lossless decomposition:
The decomposition of R into R1 and R2
is lossless when the joint of R1 and R2 produces the same
relation as in R.
24. Example of lossy decomposition:
Balance B_name
5000 Vvn
2000 kkn
8000 kkn
Main table:
decomposition
T1
T2
A_no Balance B_name
A01 5000 Vvn
A02 2000 Kkn
A02 8000 kkn
A03 2000 Kkn
A03 8000 kkn
Joined table:
The resultant joined table
from T1 and T2
which is not same as the
main table.
A_no balance B_name
A01 5000 Vvn
A02 2000 kkn
A03 8000 Kkn
A_no Balance
A01 Vvn
A02 Kkn
A03 kkn
25. A_no balance B_name
A01 5000 Vvn
A02 2000 kkn
A03 8000 Kkn
A_no B_name
A01 Vvn
A02 kkn
A03 kkn
A_no Balance
A01 5000
A02 2000
A03 8000
A_no balance B_name
A01 5000 Vvn
A02 2000 kkn
A03 8000 kkn
Example of lossless decomposition:
Main table:
T1
T2
Joined table:
The resultant joined table
from T1 and T2
which is same as the
main table.
decomposition