Create Foreign Key

To create a Foreign Key, follow the steps below:

  1. Locate the required Tables in a diagram. Both tables must have the same defined database types.
  2. Select an Associate connector in the Class Relationships page of the Toolbox.
  3. Click on the Table to contain the Foreign Key (source) and draw the connector to the other Table (target).
  4. Right-click on the connector to display the context menu, and select the Foreign Keys option. The Foreign Key Constraint dialog displays.


  1. The default foreign key name is set by the Foreign Key Name Template. To change the name to something other than the default provided by the template, select the Override Template checkbox and edit the foreign key name.
  2. In the Source: panel and the Target: panel, click on the name of each of the two columns involved in the Foreign Key relationship (in the screenshot above, the column name WarehouseID in each panel).
  3. Select the appropriate referential integrity constraint from the On Delete and/or On Update combo boxes.
  4. Click on the Apply or OK buttons to automatically generate the Foreign Key operations.

You have created the Foreign Key. The example below shows how this looks in a diagram:


Composite Foreign Key

To create a composite Foreign Key, select the required columns in each of the Source: and Target: panels and click on the OK button. The Foreign Key columns are sorted according to datatype to match the datatypes of the targeted composite Primary Key. If required, you can change the order of the key columns by clicking on the uphand and downhand buttons.


If you are defining a MySQL database and want to use Foreign Keys, you must set the table type to enable this.


This creates the composite Foreign Key. The example below shows how this looks in a diagram: