Alix Axel
Alix Axel

Reputation: 154513

Fixed Timetable DB Design

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

Answers (2)

Damir Sudarevic
Damir Sudarevic

Reputation: 22187

  • 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.

contacttime_model_01

Upvotes: 1

Hassan Syed
Hassan Syed

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

Related Questions