问题描述
当前,我正在从事更大项目的一部分,但是我不确定如何处理系统的这一部分。
每个人可以结婚多次,每次婚姻都需要有一个官员,partner1,partner2和见证人。个人可以在多次婚姻中代表这些角色。
我想知道是否有一种方法可以用更少的关联性来代表所有必要的个人,因为在查看时该图很快变成一团糟。整个系统。
请注意,也可以使用类关联仅对裁判和见证人使用一种关系:
有一个约束条件,说有两个个人是 witness 角色,一个是 officeiant
角色也可以是枚举,也可以由 isWitness
是布尔值等代替。
也可以仅使用一个类关联:
第一个约束条件说合作伙伴的角色是伙伴,第二个约束是在婚姻中有两个具有 witness 角色的个人和一个 officeiant 角色和两个 partner
角色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.
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.
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
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
这篇关于更好的UML类图结构来表示个人的婚姻的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!