1
votes

I am learning basic UML modeling and as a practice example, I am making a UML Class Diagram modeling a Hospital. The hospital has multiple Care-Centers (i.e. Maternity Center, Emergency Center etc.). A Care-Center has Volunteers assisting the Care-Center. Volunteers are also allowed to be part of multiple Care-Centers at once.

So, I have created two classes: Volunteers and Care-Center. My question is, what would the association and cardinality be between these two classes? Is this a many-to-many or one-to-many relationship? My first thought is that the Volunteer class has a multiplicity of 0..* and the Care-Center has a multiplicity of 1..*. But, i am unsure of this association and hope to get some clarification of this relationship.

2

2 Answers

3
votes

This is a many-to-many relationship.

The cardinality on the side of the Volunteer class will be 0..*, assuming a care center may not always have volunteers. This cardinality represents the number of volunteers per care center.

The cardinality on the side of the CareCenter class will be 1..*, because a Volunteer would not be a volunteer if there would not be at least one care center to volunteer for. This cardinality represents the number of care centers per volunteer.

You may choose to model class Person instead of class Volunteer, and call the association "is volunteer for". In that case, the cardinality on the side of the CareCenter would be 0..*, because not every person volunteers.

1
votes

I would say it should be a 1..* to 1..* relationship.

Rational:

  1. A Care-Center has Volunteers assisting the Care-Center.

    In other words, a Care-Center has at least one Volunteer.

  2. Volunteers are also allowed to be part of multiple Care-Centers at once.

    A Volunteer is assisting at least one Care-Center. If not, it's not a Volunteer.

Diagram:

enter image description here