In my application I have a provider that has a schedule and clients that book appointment from the schedule. I need the following features.
Provider: - Be able to specify reoccurring availability. For example Mon 9-5, Tues 10-3, etc. - Be able to black out datas. For example - not available on this Mon. - Be able to add single, not reoccurring dates/times slots. For example - This Sat 9-5.
Customer: - Be able to book single appointments. - Be able to book reoccurring appointments. (Every Mon 9-4).
So far I came up with 3 options:
- Divide the schedule into 30 min intervals and create a database entry for each interval/provider pair. Each interval can be either free or booked. When a customer books an appointment we mark the intervals as booked. The problem with this approach is that it wastes a lot of space, and I am not sure how good the search performance would be for a reoccurring booking.
- Save each availability period as an "event". If it is reoccurring, duplicate the event. When searching for free slots search the booking table to make sure that there is no over lapping booking. In this case, searching for reoccurring slots seems a bit awkward. To find all the providers that are available on Mon 9-5 for the next year we will have to search for all the matching 'events' and find all the providers that have 52 matched events.
- Save each availability period as an "event". Add a flag if it is reoccurring.When searching for free slots search the booking table to make sure that there is no over lapping booking. It makes it easier to search for reoccurring appointments. To "black out" slot that are suppose to be reoccurring we can just insert a fake booking.