Postgresql – Save schedules (working hours)

postgresql

I have an app to make appointments with doctors. Doctors have schedules (working hours).

For example, let's say doctor A usually works 10:00 – 14:00 on weekdays. I could save this info in each doctor's table; however, there are holidays, sick days and so on- maybe even short days 11:00 – 13:00. How to represent them in the PostgreSQL database?

My current approach is to create a schedules table and store the usual working hours. For doctor A on weekdays from 10:00 – 14:00, and for other days create separate tables in which we specify when the doctor cannot work.

Best Answer

save the unavailable hours as a special type of appointment