Candidate Key &&
Minimal Cover in Functional Dependencies
Functional Dependency
A -> B
B is functionally dependent on A (or)
A functionally determines B
Eg : Customer_Id -> Customer_Name
Customer_Name is identified by Customer_Id.
i.e Customer_Name is functionally dependent on Customer_Id.
How to Find Candidate Key
using Functional Dependencies
Step1
Find Closure of all attribute of LKS
X+ determine all the attributes of R then X is candidate key
Step 2.
Find the closure of attribute which cannot determine(not present
RHS)
X+ determine all the attributes of R then X is candidate key
Step3
If not find step1 and step2 then
Find the closure of attribute which cannot determine + combination
Of attributes of R.
X+ determine all the attributes of R then X is candidate key
Slide 10- 3
Attribute Closure
Example 1:Attribute Closure for one key attribute
Consider the Functional Dependencies for R(A, B, C)
A -> B
B -> C
A+ = Step1:AB [Since A -> B]
Step 2:ABC [Since B -> C]
B+ = Step1: BC [Since B -> C]
So,
A+ = ABC
B+ = BC
Note: If an attribute closure gives all the Attributes in the given
relation, that attribute will be a Candidate Key.
From the given set of functional dependencies, A is a Candidate Key.
Attribute Closure
Example 2: Attribute Closure for more than one key
attribute
Consider the Functional Dependencies for R(A, B, C,D,E,F)
AB -> C AB+ = ABCDE [Since AB->C, B->D, AD->E]
AD -> E
AD+ = ADE [Since AD->E]
B -> D
AF -> B B+ = BCD [Since B->C, B->D]
B -> C
+
AF = AFBCDE [Since AF->B, B->C,B->D, AB->C,
AD->E]
From the given set of functional dependencies, AF is a
Candidate Key.
Attribute Closure
Example 3: Key Attribute closure without candidate Key
Consider the Functional Dependencies for R(A, B, C,D,E)
A -> C A+ = ACB [Since A->C, C->B]
+ = CB [Since C->B]
C
C-> B
D+ = DE [Since D->E]
D -> E Since none of the key attribute closure have issued all the
attributes, try finding some other closure by combining the
key attributes which may issue all the attributes in the
AD+ = ADCEB [Since A->C, D->E, C->B]
From the given set of functional dependencies,
Candidate Key.
AD is a
Attribute Closure
Example 4: Key Attribute closure without candidate Key
Consider the Functional Dependencies for R(A, B, C,D,E)
A -> B A+ = AB [Since A->B]
+ = CD [Since C->D]
C
C-> D
BC+ = BCED [Since BC->E, C->D]
BC -> E Since none of the key attribute closure have issued all the
attributes, try finding some other closure by combining the
key attributes which may issue all the attributes in the
AC+ = ACBDE [Since A->B, C->D, BC->E]
From the given set of functional dependencies,
Candidate Key.
AC is a
Consider the relation scheme R(A, B, C, D, E, H) and the
set of functional dependencies A→B
BC → D
E→C
D →A
Find F+
Bc->D,D->A then Bc->A (using tran
Steps to Find Minimal Cover
Singleton attributes in Right Hand Side [RHS]
Identify Extraneous Attributes and remove it
Remove redundant dependencies
Singleton in RHS
AB -> CD
The above functional dependency should be decomposed to
singleton attributes in the RHS as below.
AB -> C and
AB -> D
Extraneous Attributes
If an attribute doesn’t any meaning to the functional dependency, we say it
is extraneous and remove it
Consider the functional dependencies
A -> B
If an LHS has more than one attribute, check whether there exists
AB -> C an extraneous (Extra/Unwanted) attribute. If so, remove it.
D -> AC
LHS which have 2 attributes is AB -> C
D -> E
A+ = ABC [Since A->B,AB-> C]
B+ = B [Reflexivity]
If an attribute Closure gives only its own attribute by satisfying
Reflexivity, that attribute in the functional dependency is
Extraneous.
So, B is Extraneous in AB-> C Implies A->C
New FDs are A->B,A->C, D-AC, D->E
Finding Redundancy Dependency and
Minimal Cover – Ex 1
Now we have to identify the redundant dependencies
from the below
New FDs 1. Remove A->B and find the attribute closure for A
A+ = AC [Since A->C] – Here if we don’t consider A->B, B cannot be found
A->B
in A+. So A->B cannot be a redundant dependency.
A->C
D-AC
D->E
A->B
A->C
D->A
D->C
D->E
Applying
Singleton to
RHS
2. Remove A->C and find the attribute closure for A
A+ = AB [Since A->B] – Here if we don’t consider A->C, C cannot be found
in A+. So A->C cannot be a redundant dependency.
3. Remove D->A and find the attribute closure for D
D+ = DCE [Since D->C, D->E] – Here if we don’t consider D->A, A cannot
be found in D+. So D->A cannot be a redundant dependency.
4. Remove D->C and find the attribute closure for D
D+ = DAEBC [Since D->C, ] – Here if we don’t consider D->C, Could be
found in D+. So D->C is the redundant dependency and should be removed.
Finding Redundancy Dependency and
Minimal Cover
A->B
A->C
D->A
D->C
D->E
5. Remove D->E and find the attribute closure for D
D+ = DACB [Since D->A, A->C, A->B] – Here if we don’t consider D->E, E
cannot be found in D+. So D->E cannot be a redundant dependency.
So, Minimal Cover will be after removing
a) Extraneous Attributes
b) Redundant Dependencies
A->B
A->C
D->A
D->E
New FD’s
after
removing
Redundancy
Minimal Functional Dependencies are
A -> B
A -> C
D -> A
D -> E
Finding Redundancy Dependency and
Minimal Cover – Ex 2
Consider the Functional Dependencies
A -> B
B -> C
A -> C
Remove A -> B and find attribute Closure for A
A+ = AC [B is not issued – Not redundant]
Remove B -> C and find attribute Closure for B.
B+ = B [C is not issued – Not redundant]
Remove A -> C and find attribute Closure for A.
A+ = ABC [A->B, B->C. C is issued – So, Redundant]
Final FDs without redundancy are
A->B and B->C
Find Minimal Cover
R(A,B,C,D,E)
F = {A->D, BC->AD, C->B, E->A, E->D}
Finding Extraneous, Redundant
Dependency, Minimal Cover
R(A,B,C,D,E)
F = {A->D, BC->AD, C->B, E->A, E->D}
Step1: Singleton RHS
Step2: Remove Extraneous Attribute
Step3: Redundant Dependency
Step1: Singleton RHS
A->D
BC->A
BC->D
C->B
E->A
E->D
Finding Extraneous, Redundant
Dependency, Minimal Cover
Step2: Remove Extraneous Attribute
A->D
BC->A
BC->D
C->B
E->A
E->D
Consider BC->A and BC->D
B+ = B
C+=BCAD so B is Extraneous in BC->A and BC->D.
Remove it.
After removing Extraneous in LHS, F =>
A->D
C->A
C->D
C->B
E->A
E->D
Finding Extraneous, Redundant
Dependency, Minimal Cover
Step3: Remove Redundant Dependency
A->D
C->A
C->D
C->B
E->A
E->D
Remove A->D, A+ = A – Not Redundant [D not arrived]
Remove C->A, C+ = CDB – Not Redundant [A not arrived]
Remove C->D, C+ = CABD – Redundant [D arrived]
New
F= {A->D,
C->A,
C->B,
E->A,
E->D}
Finding Extraneous, Redundant
Dependency, Minimal Cover
Step3: Remove Redundant Dependency
A->D
C->A
C->B
E->A
E->D
Remove C->B, C+ = CAD – Not Redundant [B not arrived]
Remove E->A, E+ = ED – Not Redundant [A not arrived]
Remove E->D, E+ = EAD – Redundant [D arrived]
Final – Minimal Cover
F= {A->D,
C->A,
C->B,
E->A,}
EC+ = ECADB
EC will be the candidate Key
R(ABCDE)
FDs {A->BC,CD->E,B->D,E->A}
Thank You
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )