Search code examples
associationsumluniquediagram

Modelling unique relationships in UML class diagrams


This question is about UML class diagrams in the analysis phase. I've made up a minimal example for illustration purposes:

UML diagram

A ticket is valid for one seat and one specific seminar. A seat can be assigned to multiple tickets, but only to one unique ticket/seminar combination. (The same goes for the seminar and a unique ticket/seat combination.)

The diagram does not reflect that. I've marked the wrong multiplicities in red.

What options (the more the better) do you know to model the requirement correctly?


Solution

  • That kind of commutative consistency check cannot be expressed either by UML or Entity Relationship diagrams. By the way, you can't express either that, from a ticket instance, the path ticket -> seat -> seminar location must lead to the same instance as ticket -> seminar -> seminar location.

    Formally, the multiplicities you marked in red are correct. A seat sees more than one ticket, just for different seminars, and the other way round.

    So the only solution I can offer is to include the requirement in the textual specification of those relationships. That's not a bad thing, as any finite set of graphical symbols could only express a subset of all possible requirements.