## Find all the possible minimal keys of a relation / How to find keys of a relation in database management system / Keys or minimal key concepts in dbms / Role of keys or candidate keys in relational database design

####
**Question:**

**2. For a relation R(A, B, C, D, E) with the set of functional dependencies F = {A → B, CD → E, B → D, E → A}, which of the following are the candidate keys (minimal keys) of R?**

(a) AB, CD

(b) AC, BC, CD, CE

(c) AC, BC, AEC

(d) A, D, DE

####
**Answer:**

**(b) AC, BC, CD, CE**

*To find a key or minimal key of a relation, we need to find the closure of certain attributes (most of the cases, the attribute(s) on the left hand side of a functional dependency). The closure that includes all the attributes of R in the result is one of the keys (minimal keys/candidate keys).
*

__Refer here for a detailed example on how to find the key of a relation.__Let us apply the closure finding algorithm on all LHS attributes of the given set of functional dependencies. The result is as follows;
Closure
of A, ie., (A)

^{+}= ABD [from A → B and B → D]. ABD is not equal to ABCDE. Hence A is not a candidate key (minimal key).
(B)

^{+}= BD [from B → D]. BD ≠ ABCDE, hence B is not a candidate key.
(E)

^{+}= ABDE [from E → A, A → B, and B → D]. So E is not a key.
(CD)

^{+}= ABCDE [from CD → E, E → A, and A → B]. As the closure of CD is results in all attributes of R. Hence, CD is one of the candidate keys.
The
other candidate keys can be found by combining two or more LHS attributes. In the
line,

(AC)

^{+}= ABCDE [from A → B, B → D, and CD → E]
(BC)

^{+}= ABCDE [from B → D, CD → E, and E → A]
(CE)

^{+}= ABCDE [from E → A, A → B, and B → D]
In
the option (C), AEC cannot be a minimal key. Because the proper subset {(AE),

**(AC), (EC),**(A), (E), (C)} contains the minimal key. But (AEC) is regarded as the super key as it is a super set of a minimal key.