Wednesday, 13 April 2022

Determining Candidate Key of a Relation using FD's

Candidate key is a single key or a group of multiple keys that uniquely identify rows in a table. A Candidate key is a subset of Super keys and is devoid of any unnecessary attributes that are not important for uniquely identifying tuples. The value for the Candidate key is unique and non-null for all tuples.
 
A set of minimal attribute(s) that can identify each tuple uniquely in the given relation is called as a candidate key.
OR
A minimal super key is called as a candidate key.

For any given relation,
  1. It is possible to have multiple candidate keys.
  2. There exists no general formula to find the total number of candidate keys of a given relation.

Example:

Find the total number of candidate keys for the relation R(ABCDE) with the following

FD={AB-->C, C-->D, B--->E }

Solution:

Consider relation and its FD's

R(ABCDE)

 AB-->C, C-->D, B--->

Eliminate the decencies from in the relation, the reaming attribute is AB and it have only one Candidate key. Check if it find all attributes or not. if not is not a CK.

AB+ ={ A,B,C,D,E}

Therefore AB is a Candidate Key 

Example:

Find the total number of candidate key for the relation R(ABCDE) with the following

 FD={AB-->C, C-->D, B--->AE }

 Solution:

Consider relation and its FD's

R(ABCDE)

 AB-->C, C-->D, B--->AE 

Eliminate the decencies from in the relation, the reaming attribute is B and it have only one Candidate key. Check if it find all attributes or not. if not is not a CK.

B+ ={ A,B,C,D,E}

Therefore B is a Candidate Key

  1. There may be more than one candidate keys in a relation.
  2. First find single attribute closure 
  3. Second two attribute combination closure
  4. Three attribute combination closure and soon 
  5. If the combination include any candidate it becomes a super key

Example:

Find the total number of candidate keys for the relation R(ABCD) with 

FD={A-->CD, D--->A}

Solution:

 R(ABCD)

 FD={A-->CD, D--->A}

 Eliminate the decencies from in the relation, the reaming attribute is B and it have only one Candidate key. Check if it find all attributes or not. if not is not a CK.

B+={B};   Not CK, it can't determine all other attributes. Now we take all combinations of 'B'

AB+={ A,B,C,D} is CK

BC+={B,C} not CK

BD+={B,D,A,C} is CK

If we take three attribute combination 

ABC, ABD, BCD since the combinations included candidate key all becomes super keys.

  1. A candidate key is always a super key
  2. But a super key can't be a candidate key.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

Computer Basics

More

C Programming

More

Java Tutorial

More

Data Structures

More

MS Office

More

Database Management

More
Top