Support
How can we help you today?

What are the differences between an Unique constraint and a Primary Key?

The difference between a UNIQUE constraint and a Primary Key is that per table you may only have one Primary Key but you may define more than one UNIQUE constraints. Primary Key constraints are not nullable. UNIQUE constraints may be nullable.

When you create a UNIQUE constraint, the database automatically creates a UNIQUE index. For MS SQL Server databases, a PRIMARY KEY will generate a unique CLUSTERED INDEX. A UNIQUE constraint will generate a unique NON-CLUSTERED INDEX.

In DeZign for Databases you can create a UNIQUE constraint in the Entity dialog under tab "Table constraints".


add a unique constraint

Add a unique constraint in DeZign for Databases.


You can add an attribute to the Primary Key by checking the PK checkbox next to the attribute name in the list of attributes under tab "Attributes". You can set the name of the PRIMARY KEY constraint in the "General" tab.


add an attribute to the primary key

Add an attribute to the primary key.






Resources

Learn Get products and technologies
  • Build your next data model with DeZign for Databases trial software, available for download directly from our download section.