oopumlclass-diagramconceptual-model

Confusion regarding association relationship in UML


To start off, I'm really confused between the association relationship between classes in UML, as there is unidirectional and bidirectional association.

I've drawn up a simple example, which is:

enter image description here

But I've looked up some examples online and i found out that most examples used the unidirectional association between the Patient class and the Doctor class.

When i interpret the diagram, i would interpret it as so where "the patient class knows about the doctor class but the doctor class does not know about the patient class." But it still didn't make much sense as in why would a doctor class not know about the patient class?

Could anyone please explain to me in a more detailed manner? It would be much appreciated.


Solution

  • Interpretation of your diagram

    Your diagram says that:

    Potential problems in your diagram

    First, there is an obvious confusion about where to place the multiplicity, because a newly appointed doctor may have no patient when he/she opens his/her practice. Conversely, a patient without any doctor is not a patient but a healthy person. So keep in mind that the multiplicity is next to the target: so 1..n is about the number of Patients for a Doctor and not the contrary.

    Then the triangle near the label "attends to" indicates the sense of reading. Here it is Doctor attends to Patient. But in general, it's patient who attend to doctors. So the triangle should be on the other side and symetric to the one you have drawn.(sorry this last point was ok, I can still improve my english ;-)

    The question of navigability

    Now to the navigability. The diagram makes explicit that a Patient knows and can find the associated Doctors. In a hospital registration system, it makes sense when a patient arrives and doesn't remember the name of the doctor to lookup for the potential doctors.

    But your diagram says nothing about the opposite navigability. This is left "unspecified". The diagram could clarify the situation either by indicating a cross on the link (i.e. no navigability), or an arrow (navigability).

    Maybe there is a reverse navigability but it's not explicit (because the drawer assumed that it was so obvious). Maybe there is indeed no navigability in that direction. So the Doctor doesn't know its Patients. This could make sense for example if the hospital registration system consider that the Patient is the Patient of the hospital and the interaction has always to go via the administration. The Doctor may in such case have a navigable association to an Appointment that has a navigable association to the Patient or other kind of indirect navigability.