## How to find the key of a relation R?, Easy way to find the candidate key of a table

__Question:__
7. Consider a relation R with set of functional
dependencies F as follows; {A → B,
C → D,
AC → E,
D → F}.
How many keys does R have and what are they?

__Solution:__
Closure:
In simple terms,
if you know an attribute (or set of
attributes) in a relation R, then what other attribute (or set of attributes)
you would determine uniquely is called the closure. We normally find the
closure of left hand side (LHS) attributes of the functional dependencies of
relation R. Closure is used to find the candidate keys of the relation. Refer here to know more about attribute closure. |

If we find the closure of all the left
hand side attributes of all the FDs given, we would find the keys of R. If the
closure includes all the attributes of R then that closure is one of the keys
of R.

__Let us find the closure of A, i.e., A__

^{+};
Result = A

Result = AB from A → B (if you know, then you
know B uniquely)

We don’t have any other FDs that have
either A or B or both on the left hand side. Hence, our algorithm stops here
and the result is AB.

The closure of A is AB. (not a key
because A

^{+}does not contain all the attributes of R)__Let us find the closure of C, i.e., C__

^{+};
Result = C

Result = CD from C → D

Result = CDF from D → F

We don’t have any other FDs that have
either C or D or F or any combinations on the left hand side. Hence, our
algorithm stops here and the result is CDF.

The closure of C is CDF. (not a key
because C

^{+}does not contain all the attributes of R)__Let us find the closure of AC, i.e, (AC)__

^{+};
Result = AC

Result = ABC from A → B

Result = ABCD from C → D

Result = ABCDF from D → F

Result = ABCDEF from AC → E

The closure of AC is ABCDEF which is
R. Hence,

**AC is the only key of R**.
**********************

**Similar topics**## How to find closure of set of functional dependencies?

## How to find closure of attributes?

## How to find canonical cover for a set of functional dependencies?

## How to find extraneous attribute?

Go back to

**Question/QUIZ page**
Go back to

**Online Quizzes home page**