Reputation: 51
My question is about UML multiplicity.i'm trying to understand the concept of multiplicity, for example, a person is allowed to have many cars but one car is for one person.if there are 2 class, person and car , it will be 1 to many and 1 to 1.However, in comparison to another example;a car and parts, 1 car will many many parts , which is 1 to many...how about parts to car ? is it 1:M as 1 part (screws) are used by many cars? or 1:1 cause that part is used only in 1 car ?
Upvotes: 0
Views: 344
Reputation: 24474
There could different connections for the same pair of classes:
So, these two classes blocks will have three differently named connections, each with its own multiplicity.
You can have even more connections, for example, people that were killed by the car, people, person, who is repairing the car, person, who has rights to drive the car, and so on, depending on your task.
If you have many different connections, it will be more understandable to create a special class for every sort of connection.
But anyway, the pair of classes by itself does not define the sort of connection. For to set the connection you have to write down much more information.
Upvotes: 1
Reputation: 954
It is always advisable to think about instances of classes when trying to determine relationships between classes and cardinality. In this case, you have cars and parts. For example:
A car can have anywhere between one and many parts (1..M), and a part can only be installed in one car at most (0..1).
Hence the relationship between car and part is 1:M (using the maximums from each side as shown below).
-------- --------
| Car | 0..1 ---------- 1..M | Part |
-------- --------
Upvotes: 1