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

Step

Action

See also

1

Locate the required Tables in a diagram.

Both tables must have defined database types.

 

Set The Database Type

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 and select the Foreign Keys context menu option.

The Foreign Key Constraint dialog displays.

 

 

5

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

6

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

 

 

7

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

 

 

8

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

 

 

Example

The example below shows how a Foreign Key looks in a diagram:

PrimaryKeyDiagram

Notes

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