Patrick
Patrick

Reputation: 1075

Two to one multiplicity? - UML Class Diagram

I was creating a class diagram and I realised I wasn't certain about multiplicity.

If a class holds two objects of another type of class does that make the multiplicity 2 to 1 or just 1 to 1?

Example:

Class diagram example

Hope the question makes sense.

Thanks in advance.

Upvotes: 2

Views: 2994

Answers (2)

Valery Belov
Valery Belov

Reputation: 31

We can suppose that class Customer has 2 fields to navigate to two instances of class Address. These navigations have different semantics and maybe different purposes. So we should to use two assotiations with multiplicities of "0..1 - 1" or "1 - 1".

Upvotes: 0

jim
jim

Reputation: 906

With multiplicities, you simply set all possible alternatives. For example, if your Customer can have either one or two Addresses, then it's 1..2. If a Customer can have either no address or 1 or 2 addresses, then it's 0..2 and so on

Upvotes: 4

Related Questions