Wednesday, June 9, 2010

Explain Candidate Key, Alternate Key, and Composite Key

A Candidate Key is one that can uniquely identify each row of a table.
Generally a candidate key becomes the Primary Key of the table.

If the table has more than one Candidate Key, one of them will become the Primary Key, and the rest are called Alternate Keys.

A key formed by combining at least two or more columns is called Composite Key.

1 comment:

  1. Candidate Key:-
    the candidate key is a column which is used for unique identification of row ,the candidate key will be a primary key or will be a part of primary key.
    i would like to say,the candidate key is one column key that mean two column cant be a part of one candidate key so that it is called as candidate key.

    Super Key:-
    the Super key is a column or set of columns which is used for unique identification of rows.
    more than two column will be part of single super key.
    Given table: EMPLOYEES{employee_id, firstname, surname, sal}
    Possible superkeys are:
     {employee_id}
     {employee_id, firstname}
     ...
     (employee_id, firstname, surname, sal}
    Only the the minimal superkey - {employee_id} - will be considered as a candidate key.

    Alternate key:-
    the Alterate key is nothing but candidate key which is not a part of primary key or which is not primary key.