apriori
apriori

Reputation: 1262

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?

Upvotes: 1

Views: 2236

Answers (3)

Vadim
Vadim

Reputation: 1

"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"

1) OCL - context Ticket inv: seminar.seminarLocation=seat.seminarLocation

2) draw Seat, Seminar and association class Ticket between Seat and Seminar - into SeminarLocation(Figure 13-70 http://msdl.cs.mcgill.ca/people/tfeng/docs/The%20Unified%20Modeling%20Language%20Reference%20Manual.pdf or Figure 14-84 http://www.utdallas.edu/~chung/Fujitsu/UML_2.0/Rumbaugh--UML_2.0_Reference_CD.pdf)

Upvotes: 0

Jordi Cabot
Jordi Cabot

Reputation: 8228

Ticket could be an association class between seat and seminar. Or just use OCL to express this constraint

Upvotes: 1

TAM
TAM

Reputation: 1741

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.

Upvotes: 1

Related Questions