Hi...........
I want to know about candidate key and alternate key in SQL Server. Please explain anyone candidate key and alternate key with an example and also explain difference between them ?
Thanks........
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vikash SinhaPosted May 6, 2013, 1:20 AM
For reffrence :http://www.thedevheaven.com/2013/05/candidate-key-vs-primary-key-vs.html
Jignesh TrivediPosted Mar 13, 2012, 12:26 AM
A Candidate Key is any column or a combination of columns in table that could be qualify as unique key in database.
multiple Candidate Keys on one table is also possible.
Candidate keys that follow all the three rules -
1) Not Null
2) Unique Value in Table
3) Static
If table have more then one candidate keys,the remining candidate keys column(s) which is not part of primary key is called Alternate Key
one differance, you can find in defination.
Candidate key use in primary key so it can mot be null but alternate key may be null in certain condition.
hopet this help.
SenthilkumarPosted Mar 12, 2012, 11:11 PM
candidate 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.
alternate keys- Any of the candidate keys that is not part of the primary key is called an alternate key.
When you talk about the alternative key, the column may not be primary key but still it is the unique key of the column. Typically identity column in the table is alternative key.
ID INT IDENTITY(1,1)
In the above attribute you have not defined as primary key, but still it will enforce the uniqueness of the column.