umlaggregationclass-diagrammultiplicity

In UML, can I have two sets of relationships between two classes?


Given the following situation:

RQ1: A flight can only be carried out by one plane

RQ2: A plane can be assigned to zero or more flights

So I have a class called Flight and a class called Plane.

I don't know if I'm over-thinking the relationship between Flight and Plane though.

So for RQ1, you'd have an association between Flight and Plane, and the multiplicity would be Flight [1] ------ Plane [1]

But then RQ2 comes along and I need an association between Flight and Plane but how do I manage the multiplicities? I think it would be Flight [0...*] ------ Plane [1]

Problem is, doing that creates two classes and two association lines and 2 pairs of/4 individual multiplicity values which doesn't sound right either.


Solution

  • Of course you can. Imagine a self relation from Person to self. One would be Father and one would be Mother (just forget for a moment that this might be different since a not so far past). So you can have as many relations between two classes as needed.

    If you use role names, the situation will clear up. So the association for RQ2 would be named assignedFlights. The carriedOutFlight role from RQ1 could also be an index into the assignedFlights (as implementation variant). But of course it can be a different association as well.