It all depends on the purpose of persons and roles in your design.
As a first thought, if a Person
can have a Role
, you’d have here two classes with an association with the following multiplicities:
- a
Person
has 1..n
Role
, meaning at least one role
- a
Role
can be taken by 0..n
Person
, which means that there are roles which might not be fulfilled at all, and roles that can be held by several users
- nothing is said about the specific number of occurrences of the association (called links) for a specific occurence of a class (called object, e.g. a labelled as “president”)
For the specific roles such as “president”, there are number of design options:
- you could have(hard-coded?) controls in your system that ensure there is only one link. You could express this in a class diagram with an explicit constraint.
- you could specify the maximum number of persons having the role as a property of the role. But this immediately suggests that there are different kind if roles (some with a maximum, some without limits).
A deeper look on this start model raises other questions:
- Is this limit of 1 president global for the system, or if the role are associated with something else (e.g. president of an entity, a jury, a company...)? In the later case, some additional classes (and requirements) would be missing.
- Is the list of roles fixed and are there a lot of rules associated with them? If yes, you could think of an enum as suggested by Bruno. If not you could just think of a string property to describe the role.
- Last but not least, do specific roles have specific behavior in the system? If yes, you could think of adding specialization of roles in your diagram (and
President
would be an obvious candidate for being such a specialization of Role
).
So it all depends on the larger picture of your design.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…