What is the difference between candidate key and composite key?

Shailesh Jaiswal picture Shailesh Jaiswal · Apr 10, 2011 · Viewed 78.4k times · Source

I am reading about candidate keys and composite keys. I came to know that

  • a candidate key can qualify as a primary key and it can be a single column or combination of columns
  • and a composite key is also a combination of columns.

For composite key I have referred this link

how do I make a composite key with SQL Server Management Studio?

Thus when both the candidate key and composite key are a combination of columns, they can qualify as a primary key. Then what is the exact difference ? Can you please explain with examples ?

Answer

Headshota picture Headshota · Apr 10, 2011

As I know candidate key is a unique key that can be used as a primary key. but not necessarily used as one.

Composite key is a key of two or more attributes that uniquely identifies the row.