0
votes

I have two entities in CoreData -- Doctors and Patients. Each patient can have several Doctors, and each Doctor can have several Patients (i.e. many-to-many relationship).

That's all easy. Now the juicy bit -- I want to track the times of all visits of Patients to Doctors.

In other words, I need to know that Patient A visited Doctor X at time 1 and Patient A visited Doctor Y at time 2.

How can this be done?


I thought about adding an NSDictionary property to Patient entity, where value would be Doctor's objectID and key would be NSDate time of visit, but it doesn't look like a good approach.

Any suggestions?

1

1 Answers

2
votes

You're missing an entity to hold the visit details. You could have an entity with PatientID, DoctorID, and visit details.

With the two entities you have, you will only be able to store details of a single visit