Предположим, мы живем в мире, где человек должен играть роль в компании, чтобы жить, а компания может вообще существовать без людей.
Если это все, что вы хотите знать об отношениях между людьми и компаниями, т.е. только факт наличия таких отношений и не более , вы моделируете это так:
![enter image description here](https://i.stack.imgur.com/aogEk.png)
Then if you want in addition to capture position
and description
of the Person
's role you use so called AssociationClass (Role
in our case):
![enter image description here](https://i.stack.imgur.com/vmOm6.png)
Each instance of Role
has four properties (both an attribute and an end of an association are Properties in UML):
- Company
- Person
- position
- description
For example, suppose a person named Scott Tiger has roles in two companies - Food Inc and Water Ltd and each company knows that Scott Tiger has role in it. Then there will be two instances of Role
(shown as tuples):
(Food Inc., Scott Tigger, eater, eats here)
(Water Inc., Scott Tigger, drinker, drinks here)
Now, returning to you question, it should be clear that an instance of Person
with name
, position
, description
attributes actually "lacks" Company
and if you "add" an Company
you will get Role
, not Person
!
So what you proposed in the end of your question is a valid design, if you model Company
and Role
and a person is just an attribute of Role
:
![enter image description here](https://i.stack.imgur.com/4PhR6.png)
It reads as follows: each instance of Company
has zero or more Role
s and each instance of Role
has only one Company
. Both ends of the association are navigable, i.e. Role
knows its Company
and Company
knows its Role
s.
UML Specification в пункте 9.5.3 дает вам следующий совет:
Свойство может представлять атрибут классификатора, memberEnd ассоциации, а в некоторых случаях и то и другое одновременно.
Полезное соглашение для общего сценария моделирования ios состоит в том, что Свойство, тип которого является разновидностью класса, является концом ассоциации, а свойство, чей тип Тип - это разновидность DataType - нет. Это соглашение не поддерживается UML.