Reputation: 154513
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?
Upvotes: 0
Views: 667
Reputation: 22187
Day
table contains list of days (Sun, Mon, Tue..), you can also use enumerated field instead.Period
table contains list of available (hourly) periods, or you could also use part of a day.Upvotes: 1
Reputation: 20485
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.
Upvotes: 1