How would you use UML to model multiple relationships between the same two classes?

John Moore



One way to show this is to simply use multiplicity on the relationship – an employee is "has" one or two addresses, as shown in the following class diagram:

But if it is important to show that one address is temporary and one is permanent, then a better way to model this would be to use two separate relationships with rolenames, as indicated below.

This second diagram would correspond more closely to the following code fragment:

public class Employee
    private Address permanantAddress;
    private Address temporaryAddress;


Note that this second approach is practical only when the maximum multiplicity is small.