Running into a couple of problems, if any one could give some ideas on how to do it

I currently am designing a booking system.
I have two tables:

  1. Dates (dateID, date, day, closed) - Already populated with dates
  2. Times (autoID, dateID, time, is_booked) - Already populated with dateID and times

What I need to do is for example:
If someone books 1-4 people then I need to find a half hour slot that is available.
However if someone books 5-8 people then I need to find an hour slot that is available.
In the ‘Times’ table I already have slots fill with times and dateID for the next 20 years.

I am getting lost in how to search for the hour slot (which would be two records one after another, as long as they are not booked)

If anyone can suggest the best way to do this it would be appreciated.

Community Page
Last updated: