Design – How to Design a Time Slot Based App

Architecturedesignnosqlsql

I have got a responsibility of designing an app which allocates time slots for doctors booking.

The scenario is like, there'll be entry for doctors and their time slot for each days. For E.g.

Doctor1 | Mon - Fri | 10:00 - 20:00
Doctor2 | Wed - Sun | 18:00 - 20:00

Now, when people will search for doctors, I need to show the available time slots for bookings.

Bookings may be stored like

Patient1 | SomeDate | Doctor1 | 10:00 - 11:00
Patient2 | SomeDate | Doctor2 | 13:00 - 14:00

So on query I need data like…

Doctor1 | Date | AvailableTime
Doctor1 | Date | AvailableTime
Doctor2 | Date | AvailableTime

So here are my queries

  1. First of all should I use NoSQL or SQL for this kind of architecture?

  2. How should I store the time slots of doctors and already booked time slots of patients?

  3. How should I fetch the next available time slots based on the information stored?

Preliminary I was thinking of .NET and SQL Server, but I don't think it's viable for such fast query performance. Also how should I relate these data specially the time slots?

Also for NoSQL, I'm not sure whether JSON based structures will be useful for querying the available time slots.

Please help.

Best Answer

  • This data can be expressed well in a relational database, so a document based database doesn't really offer an advantage
  • Using the database's querying features to narrow down the booking to the doctor and date(s) you're interested in and doing the actual processing in the application should work well. There are perhaps a few hundred bookings per month and doctor, fetching all those rows is still cheap.
  • If necessary you can always add a caching layer or denormalize information about fully booked dates. But I don't expect this to be necessary.
  • The total amount of data will be quite small, so you probably won't need sharding
  • Many NoSQL databases favour sharding over transactions, which is likely not a good trade-off for you since you won't need sharding.
Related Topic