Saturday, July 28, 2012

Candidate Key, Primary Key, Unique Key :


Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key.

Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key.

1)Primary key is nothing but it is uniqly identified each row in Table.
2) Primary key does not Allows Duplicate values and Null values.
3) Primary key is default Clustered indexes
4) one table can have only one Primary key.

Unique Key:
1)Unique Key is nothing but it is uniqly identified each row in Table.
2) Unique Key does not Allows Duplicate values but allows only one Null value.
3) Primary key is default Non- Clustered indexes

Primary key: -
                     1) Can only one in a table
                     2) We can't insert duplicate value or same value
                     3) Can use as a foreigner key for other table
                     4) It never allow Null values.
Unique key: -
                     1) there can be more than one unique key in one table
                     2) Unique key can have Null Values
                     3) It can't be a candidate key

No comments:

Post a Comment