开发者

Fixed Timetable DB Design

开发者 https://www.devze.com 2022-12-13 06:31 出处:网络
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 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.

Fixed Timetable DB Design


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消