In the UML, a Property is an association end and can be owned either by the association or by a participating Classifier, which is typically a class. When a Property is owned by a class, it's called an attribute. For example, an attribute Book::author
could get one of the following notations (where a dot should be drawn at the author association end of the right-hand side diagram):
The attribute could be used in constraint expressions like: self.author
or mybook.author->count()
This is straightforward for binary associations. But I have doubts how this works with ternary (or more generally N-ary) associations, for example:
Is it correct to state that Project
would have an attribute participant
and an attribute role
since these are the opposite member ends of the association?
And considering that participant
and role
are not independent, how to make use of their correlation in constraints, for example to refer to the contributors having a given role, or to the set of (participant,role)
-tuples to constrain its ->count()
to less than 10?
Of course, in your example, attributes like Project::participant
or Project::role
do not make any sense for representing ternary links.
The UML spec (in 11.4.3.1 Classes) states that
Attributes of a Class are Properties that are owned by the Class. Some of these attributes may represent the ends of binary Associations.
They don't mention the possibility of attributes as ends of non-binary Associations.
In 11.5.4 (page 202), as pointed out by @Christophe, they say
Ownership of Association ends by an associated Classifier may be indicated graphically by a small filled circle, which (...) we will term a dot.(...) The dot shows that the model includes a Property of the type (...). This Property is owned by the Classifier at the other end.
The important concept here is "the other end", which is also called "the opposite end" in other statements of the spec. It implies that there must be a unique other end of the association.
Consequently, since Attributes are association ends (= Properties) owned by the Classifier at the opposite end, they can only be the ends of a binary association.
This implies that for n-ary associations, the participating classes cannot own any end and can therefore not have (reference) attributes like Project::participant
.
Also, using common sense: what would be the possible meaning of an attribute like Project::participant
(or better: Project::participants
)? It could be intended to represent the collection of all Contributor
objects that participate in an instance/link of the ternary association Project
-Contributor
-Role
. This could be defined as a derived attribute using an OCL expression. But it does not allow to represent/implement/reconstruct the ternary association.
In OOP, you could have a property like Project::contributorByRole
the values of which would be ordered pairs from the Cartesian Product of Contributor
and Role
. Such a property represents/implements the ternary association. But, afaik, UML does not define Cartesian Product types and does, therefore, not support such tuple-valued properties.