This is frequently asked question from database interviewer. Difference between primary and unique key in databases.
  1.  Primary key and unique keys show the uniqueness of columns in a table. Primary key is used to relate with other tables in databases as foreign key. Unique keys show uniqueness of columns.
  2. Primary key can not be NULL ever but unique key can be NULL but just once. For example registration number is always unique for student but it is compulsory for a student to have registration number and email is unique column, No two or more students can have same email id but there is a chance that some student have not been assigned email id yet so email id of a student can be null but only once.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *