The primary key constraint ensures that the attributes, which are declared as primary keys must be unique and not null. The primary key constraint enforces entity integrity for the relation and constrains the relation in the following ways:
The unique constraint ensures that a particular set of attributes contains unique values and hence, two tuples cannot have duplicate values in specified attributes. Like primary key, it also enforces entity integrity.
Unique constraint is preferable over primary key constraint to enforce uniqueness of a non-primary key attribute. This is because
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.