What is difference between candidate key and primary key

Questions by suresh.kalyadapu

Showing Answers 1 - 4 of 4 Answers

veerbahadur

  • Dec 24th, 2008
 

Any attribute that is uniquely identify a row in a table is candidate key for the table. We select one of the candidate key as Primary key. All candidate keys which are not chosen as "primary key" are Alternate keys. The key which uniquely identify the rows of the table and which is made up of more than one attribute is called Composite key. 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.

Key/SuperKey: It is the column or set of columns that can be use to uniquely identify the records/tuples in a table. There can be possibility of multiple SkeyuperKey in a relation/table.
Candidate key: The minimal SuperKey is considered as a candidate key.
There can be possibility of multiple candidatekey in a table.
Primary key: Among multiple candidate key Database Administrator can choose only one key as a Primary key.
Example: Suppose a table Rel1 is having multiple unique columns as below.
Rel1 (SSN, PAN, PASSPORTNO, Description)
DBAdministrator or DBArchitect can choose any unique column which do not have any NULL values in it as PK.
Unique key: It is the key column or combination of columns with a maximum of one NULL value in it.
In short- PK is having a column or combination of columns which is UNIQUE and NOT NULL. Where as a Unique key can have all UNIQUE values with maximum of a single NULL .

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions