Sankey Solutions interview question

Difference between primary key and unique key

Interview Answer

Anonymous

18 Apr 2019

Primary Key: There can only be one primary key in a table In some DBMS it cannot be NULL - e.g. MySQL adds NOT NULLPrimary Key is a unique key identifier of the record It's also a column or group of columns that can identify a uniqueness in a row. So the Primary key is just another name for unique key, but the default implementation in SQL Server is different for Primary and Unique Key. Unique Key: Can be more than one unique key in one table Unique key can have NULL valuesIt can be a candidate key Unique key can be NULL ; multiple rows can have NULL values and therefore may not be considered "unique" It's a column or a group of columns that can identify a uniqueness in a row.

2