This is frequently asked question from database interviewer. Difference between primary and unique key in databases.
- 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.
- 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.