Primary vs Unique Candidate vs Composite Keys

Primary Key Unique Key 
Can be only one in a table Can be more than one unique key in one table.
It never allows null values Unique key can have null values
Primary Key is unique key identifier and can not be null and must be unique. It can’t be candidate key
Unique key can be null and may not be unique.
 All databases allow the definition of one, and only one, primary key per table.
Candidate Key Composite key
A candidate key is a column, or set of columns, in a table that can uniquely identify any database record without referring to any other data. Each table may have one or more candidate keys, but one candidate key is special, and it is called the primary key. This is usually the best among the candidate keys.     When a key is composed of more than one column,
it is known as a composite key.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s