I am making a appointment system for various businesses.
Each business provides us the following type of information (system already impemented):
Weekly schedule which day of week id open and close where stored upon
weekly_schedule
:- business_id
- day_of_week
- open
- time_open
- time_close
Deviations from the schedule stored upon
schedule_deviations
for example a business may be open as Christmas in different hours than normal days:- business_id
- datetime_from
- datetime_to
- open
- reason_national_holiday
- time_open
- time_close
What I was tasked to do, is to generate a schedule callendar in order to be displayed upon web. In this callendar user will select a date and a time and will make an appointment.
For that I have 2 approaches:
Generated once calendar is asked.
Populate a table
schedule_callendar
upon CRUD action on tablesweekly_schedule
andschedule_deviations
, where for a course of a month or year for each business will generate the following records:- date
- time
- store_open
- deviated
- deviated_because_holiday
And I am in split desition. Generate them upon read but it may be time consuming to do it OR generate it upon the writing into db where the write may be slow but the read to the callendar may be fast.
Also, for the latter I can either do it using code (in my MVC Model) or a trigger to generate it. What parameters should I take into account in order to decide what is the best course of action?