SQL SERVER – WHAT is Candidate key, Alternate key, Composite key

A candidate key is one that can identify each row of a table uniquely. 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. A key formed by combining at least two or more columns is called composite key.

Reference : Dilip Kumar Jena ( https://sqlexplore.wordpress.com )

Advertisements

3 thoughts on “SQL SERVER – WHAT is Candidate key, Alternate key, Composite key

  1. This is really a good answer.
    Please let me know can we have more then on Primary key column in one table while creating a table?

    • hmm.. its quite a good and debatable topic as far as my knowledge is concern, there are two things that you need to take care.
      1) Why you want to have two columns or want to make two columns as primary.
      2) If you want to have two columns primary having no relation and posses two different kind of values.

      Now here is the answer,
      1) We can have composite keys that span across multiple columns, but the thing is that the combination of those columns values are unique.

      So, you need to make sure that what your requirement is and what data are you going to store in those columns.

      Thanks,
      Dilip

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s