简体   繁体   中英

UML Class Diagram - Notation for 'OR'

I have 4 tables:

Doctors ID,Name,roomNumber

Appointments ID,whenOccured,ifAttended

Patients ID, name, address

DPappointments DoctorID,PatientID,AppointmentID

this roughly becomes

在此处输入图片说明

However, i now want to change it such that an appointment can be made to see either a Doctor OR a NURSE?

How can i change the class diagram to reflect an 'OR' type relation?

Depending on the rest of your model's structure, there are different solutions. I supose there is also a class Nurse and that id does not have any special relationship with the Doctor (like inheritance from Employee or similar). So, this would be a generic solution.

Add add an association between Appointment and Nurse, similar to the existing one with a Doctor. The corresponding multiplicity on the Doctor (and Nurse) side should be 0..1 and an additional rule should be added - an Appointment object must have either a link to the Doctor object or to a Nurse object .

This rule could be specified in OCL (if you like a formal style) or as a simple textual note on the diagram.

There are some other ways to model this, with no additional restrictions, but the model itself would (maybe) be necessery complicated. For example, you could derive Doctor and Nurse from an abstract class - AppointmentRespondent and link it with the Appointment using the multiplicity 1..1 on that side. This model permits more flexibility and is more exdensible (easy adding new potential AppointmentRespondents), no OCL, no restrictions.

It's up to you to chose the method that is more in line with your model and future extensions.

PS Not that this is not an OR-type of relation, but rather XOR - in each Appointment there MUST be somewhone on behalf of the hospital (this is a reasonable guess :)).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM