There are four methods for creating constraints within the ER Modeler. These methods work for Primary Key Constraints, Unique Constraints, and Check Constraints.

  1. Right-clicking a table entity in the sheet view and selecting "New Unique Constraint", "New Primary Key Constraint" or "New Check Constraint" from the context menu.
  2. Right-clicking a table node in the model node browser and selecting "New Unique Constraint", "New Primary Key Constraint" or "New Check Constraint" from the menu.
  3. Expanding a table entity node in the model node browser, right-clicking on the constraints node for that table and selecting "New Unique Constraint", "New Primary Key Constraint" or "New Check Constraint".
  4. Left-clicking a table entity in the sheet view and choosing Edit >New Unique Constraint, "New Primary Key Constraint" or "New Check Constraint" from the ER Modeler application menu bar while the table entity is still selected in the sheet.

Primary Key Constraints

When the New Primary Key Constraint properties window appears, it must be named and columns must be included in the constraint. The column names on the left can be clicked to select them for participation in the constraint. Their constraint type "Primary Key" is indicated in the constraint column and the sequence in which they are clicked determines their order number in the Sequence column. Details on the Primary Key Constraint can be selected at the bottom of the properties window. Details at the bottom of the properties window vary based on database vendor and version. The Primary Key Constraint indicator in the Node Browser and Sheet view within a table entity resembles a key. The SQL Preview tab allows viewing of the DDL that the constraint creates when the model is converted into a script during forward engineering.

Unique Constraints

When the New Unique Constraint properties window appears, it must be named and columns must be included in the constraint. Its table, database, and schema are displayed based on the table's corresponding information.  The column names on the left can be clicked to select them for participation in the constraint. Their constraint type "Unique" is indicated in the constraint column and the sequence in which they are clicked determines their order number in the Sequence column. Details at the bottom of the properties window vary based on database vendor and version. The Unique Constraint indicator in the Node Browser and Sheet view within a table entity resembles a table with a protruding node at the top. The SQL Preview tab allows viewing of the DDL that the constraint creates when the model is converted into a script during forward engineering.

Check Constraints

When the New Check Constraint properties window appears, it must be named and a condition must be entered. Its table, database, and schema are displayed based on the table's corresponding information. There is an option to exclude the check constraint from replication. Details at the bottom of the properties window vary based on database vendor and version. The Check Constraint indicator in the Node Browser and Sheet view within a table entity resembles table with a check at the top. The SQL Preview tab allows viewing of the DDL that the constraint creates when the model is converted into a script during forward engineering.

Sample Completed Table with Constraints

The screenshot marked "Sample Completed Table with Constraints" contains two tables in a DB2 iSeries v5.4 database.  The table on the left contains a Primary Key Constraint, a Unique Constraint, and a Check Constraint as indicated by the Model Node Browser's Constraints tree.

Sheet - Table - Right-Click -
New Constraint

Node Browser - Constraints Node -
Right-Click - New Constraint

Node Browser - Table Node -
Right-Click - New Constraint

Edit Menu - New Constraint

Primary Key Constraint Properties

Unique Constraint Properties

Check Constraint Properties

Sample Completed Table with Constraints


  • No labels