What Primary key and Unique key?

 Posted by Poster on 4/24/2008 | Category: Sql Server Interview questions | Views: 11054

Primary key are used with Foreign key to enforce referential integrity. Unique constraints allows nulls to be inserted into the field. But there can't be null in Primary key.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Vishvvas on: 9/3/2011 | Points: 10
Lets walk through a little deeper. As many would be aware of ER (entity relationship) which form the foundation of designing the database. The set of attributes (one or more) whose values uniquely identify the entities are defined as super keys. Candidate keys are minimal Super keys with null values. Such candidate keys are called as Unique keys for general usage. Out of such many candidate keys, one of the keys with not null values is selected to be a primary key.
Entity set is generally gets translated into the tables in RDBMS.
Posted by: Vivekjj on: 10/5/2012 | Points: 10
primary key and unique key does not allow repeated values but one difference is primary key not allow null values but unique key allows null values

Login to post response