Create a Foreign Key [Enterprise Architect User Guide]

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

Create a Foreign Key

Create a Foreign Key



See also


Locate the required Tables in a diagram.

Both tables must have defined database types.


Set The Database Type


Select an Associate connector in the Class Relationships page of the Toolbox.




Click on the Table to contain the Foreign Key (source) and draw the connector to the target Table.




Right-click on the connector and select the Foreign Keys context menu option.

The Foreign Key Constraint dialog displays.




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.

Optionally, you can create a Foreign Key Index automatically using the Create Index on Foreign Key field. You can control the name of the automatically generated Foreign Key Index by setting the template.


Define Foreign Key Name Template


Define Foreign Key Index template


In the Source: panel and the Target: panel, click on the name of each of the two columns involved in the Foreign Key relationship.




From the On Delete and/or On Update combo boxes, select the appropriate referential integrity constraint.




Click on the Apply or OK buttons to automatically generate the Foreign Key operations.




This example shows what a Foreign Key looks like in a diagram:



For MySQL databases, Foreign Keys are supported for InnoDB tables only
InnoDB is the default MySQL storage engine as of version 5.5; if you are modeling a MySQL database that is earlier than version 5.5 and you want to use Foreign Keys, you must set the Engine Tagged Value to InnoDB

Learn more