Model Foreign Keys
A Foreign Key consists of a collection of columns (UML Attributes) that together have some operational meaning - they enforce a relationship to access data in a related Table via its Primary Key.
Foreign keys are modeled in Enterprise Architect as operations with the stereotype FK. The operation's parameters are the columns involved in the key.
Access Tools | Database Builder | Right-click on Table | Add new Foreign Key on <table name>
On the Select Parent Table in new foreign constraint dialog, double-click on the parent Table for the key. This Table must have at least one column with a Primary Key and/or at least one unique constraint; if it has no constraints, the system generates a simple Association relationship between the two Tables.
The Foreign Key Constraint dialog displays. See the Help topic Create a Foreign Key.
The parent Table constraint defines the columns that are involved in the Key, and the system automatically assigns columns from the child Table to match those columns. A simple key has one column pair, whilst a composite key has several column pairs.
Edit or Delete a Foreign Key
Right-click on the Foreign Key in the hierarchy in the left-hand panel, and click on the Foreign Key Constraint option. (Do not use any other option in the Database Builder.)
|·||To edit the Foreign Key, adjust the fields as indicated previously|
|·||To delete the Foreign Key, click on the Delete button; a prompt displays to confirm the deletion (and the deletion of the Foreign Key Index , if one exists) - click on the Yes button|
Deleting a Foreign Key leaves an Association in place, which you can either edit or delete (right-click and select Delete 'association').
|·||When you add a constraint to a Table, one of the constraint type options is FK; do not use this option to attempt to create a Foreign Key|