I am creating a small booking application with Laravel. It lists some centers. Each center has its own unique rooms. Each room may be booked several times (with dates). From my application, I post the 'from' and 'to' dates. I need to add the date range as booking dates of a particular room. Remember, a room can be booked more than once, but to a limited number of times. I need this because I want to mark the booked days with different colors in a calendar in the front-end.

Just in case you want to know, I'm more concerned about the booked dates more than everything else.



I want advice on how to setup the database tables and columns. Then, how to set the booked dates of a room. Is it enough if I set a Start and End date to the booking, or do I need a row for each day that is booked?


  • Will there be also recurring booking?
    – vijayp
    Commented Apr 5, 2015 at 5:08
  • @vijayp Yes, there will be.
    – Amar Syla
    Commented Apr 5, 2015 at 5:17
  • It is not clear what your problem is. Are you asking about checking availability? Is it about INSERTing multiple rows in one statement? Please edit your question to make it clearer. Commented Apr 5, 2015 at 11:48

1 Answer 1


Your question is not very clear on this point but I'm assuming you want to find overlaps with a proposed, new booking.

Let the values for the proposed booking be held in the variables @StartDate, @EndDate and @RoomID. The SQL will be

from TheBookingTable as t
where t.RoomID =  @RoomID
and T.StartDate <= @EndDate
and T.EndDate >= @StartDate;

This query will return all current bookings which overlap your proposed booking, or an empty set if none exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.