Tutorials...Videos...Knowledge Base...And More............

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". 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.

Back to Knowledge Base DeZign for Databases