I want to let my users specify which hours / days they want to be contacted, I though of creating a fixed timetable with the 7 days of the week and let the user specify which hours he has free.
I'开发者_如何学运维m having a little trouble figuring out how I would store that info in the database, can anyone help me with a good table design for this situation?
- The
Day
table contains list of days (Sun, Mon, Tue..), you can also use enumerated field instead. - The
Period
table contains list of available (hourly) periods, or you could also use part of a day.
I assume dates are not involved. If dates are involved, remove day and change the time type to date-time types.
So you need entries that look like this·
person_id - day(int 0-7) - time_low - time_high.
Thats all you should need to represent the data. Availability is represented by the ranges between time_low and time_high.
You will need application logic to merge overlaps and resolve overlaps. It should not be too hard.
精彩评论