2

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.

Patrick
  • 1,045
  • 1
  • 9
  • 21
  • 1
    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. – jim May 19 '16 at 15:10
  • Good that's what I wanted to clarify. Make it the answer and I'll mark it as correct. Cheers mate. – Patrick May 19 '16 at 15:11
  • A bit off topic, but in most cases I've seen addresses can be shared by multiple customers, and by other things (organisations, deliveries,...). Your model does not allow that because of the composite and the multiplicity on the customer side. – Geert Bellekens May 20 '16 at 07:47

2 Answers2

4

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

jim
  • 906
  • 7
  • 14
0

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