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

How To:

To create a Foreign Key, follow the steps below:



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 other Table (target)



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

Define Foreign Key Name 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



The example below shows how a Foreign Key looks 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 ensure the Engine Tagged Value is set to InnoDB

Learn More: