Question

What is the differences between candidate key and primary key?

Was it helpful?

Solution

I think this post does a pretty good job of explaining the difference.

To summarize:

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.

A table can have multiple Candidate Keys that are unique as single column or combined multiple columns to the table. They are all candidates for Primary Key.

OTHER TIPS

Candidate keys can take null values whereas primary keys can never be null. That is also one of the significant differences.

Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as a unique key in the database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as a 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.

Candidate keys can take null values whereas primary keys can never be null. That is also one of the significant differences.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top