### Candidate Key:

An attribute or the combination of attributes is called candidate key if and only if:

- They derive all the attributes of the relation.
- They are the minimal subset of the super key.

Note:

- Candidate keys can be either simple or composite.
- Minimal subset is not with respect to the no of attributes however it always refer to the minimal level of subset which does not have any proper subsets that derives all the attributes of the relation.
- A relation can have more than one candidate key

**we can determine candidate key using below steps:**

- Find out attribute closure for each of the determinant. How to find out attribute closure using given set of functional dependencies.
- Check which determinant closure derive all the attributes of the relation.
- Declare all the determinant whose closure set contains all the attributes, as candidate key
- In case none of the determinant of the given functional dependencies derives all the attributes, then we shall choose the best closure based on more no of attribute derived and then combine the missing attribute to the best closure and make sure it is the minimal subset before it gets declared as candidate key.

**Example:**

R(A. B, C, D) {A->C, B->D}

A** ^{+ }**= {A,C}

B** ^{+}**= {B,D}

as none of the determinant’s closure set derives all the attributes, hence we can combine both AB and get the closure

**AB**** ^{+}**= {A,C,B,D}.

AB^{+ }derives all the attribute hence AB is the candidate key.