Better UML class diagram structure to represent marriage of individuals

走远了吗. 提交于 2020-07-22 10:57:27

问题


Currently I am working on a part of a bigger project, but I am not quite sure how to approach this part of the system.

UML class diagram made in PowerDesigner

Each individual can be married multiple times, each marriage needs to have an officiant, partner1, partner2 and witnesses. Individuals can represent these roles in multiple marriages.

I am wondering if there is a way to represent all of the necessary individuals with less associations, since the diagram quickly turns into a mess when looking at the whole system.

Updated class diagram


回答1:


Replace partner1 and partner2 by partner with multiplicity 2, and of course same for partnerWitness

individualId and marriageId are wrong because written underlined that mean they are static. Probably they are primary-key, but they are instance-member, not class-member. You can also name them id, useless to have a prefix

What is statusPartner ? is that can be supported by a class-association ?

The separated relation Individual -> Marriage is wrong because like that it can be for a marriage which not the same as the marriage the individual participate whatever its role, and this is not what you want. So remove it and use bidirectional relations

From your remark

statusPartner is simply status of the partner before marriage (divorced, widow and so on)

that enforce to manage it through a class-association :

  • With only partner you cannot know for who is statusPartner1 and statusPartner2, of course you do not have that problem in case of a class-association.
  • You can also move that attribute in Individual but in that case it exist not only for the partner and that has no lot of sense to have it

So for instance :

Note it is also possible to use only one relation for both the officiant and witness using a class-association :

with a constraint saying there are two Individuals with the role witness and one with the role officiant

The role can also be an enumeration or replaced by the isWitness being a boolean etc.

It is also possible to use only one class-association :

with a first constraint saying the role of a Partner is partner and a second saying at a marriage there are two Individuals with the role witness and one with the role officiant and two with the role partner




回答2:


  1. Perfectly! But notice that in the beginning there were partner1Witness and partner2Witness, that is, each partner has his own witness.
  2. first constraint saying the role of a Partner is partner and a second saying at a marriage there are two Individuals with the role witness and one with the role officiant and two with the role partner may be diagramming

Possible scheme in the picture



来源:https://stackoverflow.com/questions/62967168/better-uml-class-diagram-structure-to-represent-marriage-of-individuals

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