Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Primary Keys

A Primary Key is a column (or set of columns) that uniquely identifies each record in a Table. A Table can have only one Primary Key. Some DBMSs support additional properties of Primary Keys, such as Clustered or Fill Factor.

Access Tools | Database Builder | Click on Table > Constraints

On diagram | Right-click on Table | Features & Properties | Attributes > Constraints (F10)

Create a Primary Key

In Enterprise Architect you can create a Primary Key from either the 'Columns' tab or the 'Constraints' tab. In either case, when you add a column to a Primary Key constraint, any diagram containing the Table element shows the prefix 'PK' against the column name.

Create a Primary Key - from the Columns tab

Step

Action

See also

1

Either:

  • In the Database Builder, click on a Table with one or more defined columns, and click on the 'Columns' tab, or
  • On a diagram, click on a Table and press F9 to display the 'Columns' tab

2

For each column to include in the Primary Key, select the 'PK' checkbox.

If a Primary Key constraint is not previously defined for the current Table, the system will create a new constraint using the Primary Key Name template.

DDL Name Templates

Create a Primary Key - from the Constraints tab

Step

Action

See also

1

Either:

  • In the Database Builder, click on a Table with one or more defined columns, and click on the 'Constraints' tab, or
  • On a diagram, click on a Table and press F10 to display the 'Constraints' tab

2

Overtype the New Constraint text with the Primary Key name, press the Enter key and click on the 'Type' field drop-down arrow, and select 'PK'.

Database Table Constraints

3

Assign the required columns to the PK constraint.

4

Set the Primary key's extended properties using the property panel.

  • Fill Factor is a numeric value between 0 and 100
  • Is Clustered is a boolean value that determines the physical order of how the data is stored; for most DBMSs the Is Clustered property defaults to True for Primary Keys

Non Clustered Primary Keys

Remove columns from a Primary Key

You can remove columns from a Primary Key using either the 'Columns' tab or the 'Constraints' tab.

Remove columns from a Primary Key - using the Columns tab

Step

Action

See also

1

Either:

  • In the Database Builder, click on the Table with the Primary Key, and click on the 'Columns' tab, or
  • On a diagram, click on a Table and press F9 to display the 'Columns' tab

2

Against each column you want to remove from the Primary Key, deselect the 'PK' checkbox.

If you have removed all columns from the Primary Key constraint and the Primary Key is no longer needed, it must be manually deleted.

Remove columns from a Primary Key - using the Constraints tab

Step

Action

See also

1

Either:

  • In the Database Builder, click on the Table with the Primary Key, and click on the 'Constraints' tab, or
  • On a diagram, click on a Table and press F10 to display the 'Constraints' tab

2

Unassign the columns on the PK constraint, as necessary.

Database Table Constraints

Learn more

Learning Center topics

  • Alt+F1 | Enterprise Architect | Database Engineering | Physical Data Model | Add Primary Key