Reputation: 2356
I'm new to NoSQL databases (RavenDb) and I would want to know which is the best way to model the following situation:
I am doing a booking calendar for medical consultations. There are several types of medical consultations based on medical specialty and type of consultation (first or subsecuent). So for example, a first medical consultation of cardiology takes 30min and a subsecuent one 15min. Each specialty has its duration.
The problem comes when there are some doctors whose consultation time is different from the general. So, usually, a first cardiology consultation takes 30min, but when the doctor is John the Rapid it only takes 20min.
For this cases we used to have a table relating consultation types with these rare doctors with the special duration inside. So we made a left join with this table and if there was a record for this type of consultation and selected doctor, we applyed the time in this table. If there wasn't a record, we took the standard value of consultation type.
Should I continue using this approach and querying another collection to see if there are different timings, or is better to include this info in the collection of consultation types?
Upvotes: 3
Views: 65
Reputation: 3839
Why not simply create a 'Doctors' collection where each document can be like:
{
"Name": "John the Rapid",
"speciality": "Cardiaology",
"FirstConsultationTime": "20",
"SecondConsultationTime": "10",
.....
}
and that's it.
Optionally, for 'regular' doctors, you can create skinnier documents within this same collection that look like:
{
"Name": "Some other name",
"speciality": "Cardiaology",
.....
}
and when you query for the doctor,
if the 'time' field doesn't exist then you use some default value (30 min, and 15 min) ...
You may want to read: https://ravendb.net/learn/inside-ravendb-book/reader/4.0/3-document-modeling#document-modeling
Upvotes: 2