Search code examples
umlclass-diagram

Better UML class diagram structure to represent marriage of individuals


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


Solution

  • 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 :

    enter image description here

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

    enter image description here

    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 :

    enter image description here

    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