Skip to content
Advertisement

Database table design for ‘availability’ within time ranges per day

I am working on a meeting scheduling web-app, where a person can share their availability for specific time ranges within the day.

E.g. A user is available 3 time-ranges within the day, from 09:10 to 10:00, 13:00 to 14:00 and 16:30 to 17:15.

This can go on for 6 days per week, from Monday to Saturday.

What I came up with:

But I have no clue how to query between time ranges and get all the users who are available at that time, If I search for a user who is available from 16:30 to 16:50 I am not really sure how to do that.

I’m using PostgreSQL

Advertisement

Answer

I would suggest you to first have a timerange table which is keeping the time ranges at the 5 minute interval, something like below. You should not keep time_range as textual field. Keep them in the time datatype.

TimeMaster

Every interval representation should utilize this time master table. In this way, you can easily do all time calculations.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement