Cardinality in class diagram

Asked

Viewed 270 times

4

When I diagram classes or MER, the cardinality should be defined.

As an example: A doctor consults from 0 to n patients; a patient is consulted by 0 or 1 doctor. Why the 0?

  • A doctor may not have consulted any patients yet. The patient is strange, because if he is a patient, it is automatically assumed that he has consulted at least once, in this case it would be 1:n doctors.

  • I imagine the fact that the patient has a record does not imply that he has a doctor.

  • Zero means that from that side there may be no record. The reason you have to ask for whom you have defined that it is so.

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

1 answer

3

It is always very difficult to talk about generic and abstract cases like this. The concrete case may be different.

As far as I understand there’s no need for the doctor to have patients. So it could be 0 to N. Of course you can establish a business rule that requires that he have any related patients. And since you are setting a minimum of 1, maybe you can define a minimum greater than 1. For me this rule does not make much sense, but it is as I said. Every business with its rule.

Even the patient doesn’t need to be tied to a doctor. In this case there is a greater chance of having a doctor in certain situations. I would not make this demand either, I see no reason to have it, but if whoever is asking for it says that it justifiably needs some extra restriction, there is no reason not to.

What I would even think is if the patient can’t be tied up to N doctors. Why is there exclusivity? It may have, but I find it unlikely in a hospital or clinic. Even if the clinic only has a doctor, this is a circumstance.

Of course if the system is controlling the doctor’s allocation these rules may be different. But I don’t know if they would be. Nothing prevents the doctor from attending several patients simultaneously as well as a patient may be receiving attention from several doctors, perhaps forming a joint.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.