UML ternary association

北城余情 提交于 2019-11-30 18:44:10

There seems to be some ambiguity in the specification of multiplicities on ternary associations. See also this paper

But I understand it like this:

The multiplicity says something about how many times an instance may be present in this associations for any given tuple of linked instances.

As an example, consider the following (traditional) family


I would understand that as

In any given family there must be one father, one mother and zero or more children.

If we apply that to your case then I come to something like this:


I understand that as

For any given Offering there must be exactly one market, one department and one or more products

That seems to satisfy more or less all of your constraints

  • A Product can only be offered to one market by one department
  • A Department can offer multiple products, but one product can only be offered to one market

I don't think it's waterproof though, but as the paper already stated, UML does not have enough tools to make a waterproof design with the multiplicities on the ends alone. So for good measure, your constraints should also be modeled as UML constraints.

Disclaimer: Ternary associations are really nice for academical discussions, but are not really used in the (IT) industry, probably because they are so hard to understand.

This unspecific ternary association just tells that you have relations where

  • Market controls Department-Product,
  • Department controls Market-Product and
  • Product controls Department-Market.

There is no statement as to how the single classes control the other two.

The UML specs is not defining the ternary operator in detail. So using that element seems to be on your own risk. You could blame OMG for using but not defining it more than

Any Association may be drawn as a diamond (larger than a terminator on a line) with a solid line for each Association memberEnd connecting the diamond to the Classifier that is the end’s type. An Association with more than two ends can only be drawn this way.

and a single example in a picture on p. 202.

The simple association class

tells you that the Product is in between Department and Market where the multiplicity 1 tells that there's only one Market for a Department. That's more what your requirement sounds like.

N.B. It does not make much sense to split hairs regarding the requirements, so as "is there a Product without a Market". Those are details which need to be discussed with domain specialists before being fixed in a model.

The model in the answer of Geert Bellekens is correct, but his explananation is confusing. The ternary association "Offering" with its multiplicities (cardinality constraints) cannot be explained by the statement

For any given Offering there must be exactly one market, one department and one or more products

but rather by stating that

  • a combination of department and product is linked to exactly one market
  • a combination of market and product is linked to exactly one department
  • 易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!