How to Add a Foreign Key to a Database Table

A foreign key is specified between a pair of entities by adding a relationship between the two classes and adding key/qualifiers to the role touching the referenced class. On a class diagram, this results in a line between two classes, with a box containing the key/qualifiers at the referencing class.

The notation for linking pairs of fields in two different classes is the same for foreign keys as for generated assignments. The class diagram will show two classes joined by a line with pairs of linked attributes in a box at one end of the line. The first name in the pair refers to an attribute in the nearer class, the second name refers to an attribute in the other class.