I think you need to decide on how to store each booking range.
Let’s say person a books 3 beds in room1 (limit 6) for the dates 1st, 2nd 3rd of March.
AFAICT, you have 2 main ways to think about storing that.
1 Store the number 3 in the bookings table in room1 with a date range in
bedsbooked;
=========
bookingid | 23
aDate | 2008-03-01
dDate | 2008-03-03
bedsbooked1 | 3
bedsbooked2 | 0
OR: store each booking, date, bed “instance”.
bedsbooked;
=========
bookingid | 23
bookingDate | 2008-03-01
bedsbooked1 | 1
bedsbooked2 | 0
bookingid | 23
bookingDate | 2008-03-02
bedsbooked1 | 1
bedsbooked2 | 0
bookingid | 23
bookingDate | 2008-03-03
bedsbooked1 | 1
bedsbooked2 | 0
The questions you need to ask yourself might include:
What advantage does each method present?
What drawback does each method present?
Any flexibility you can find may have implications for your client, for example the second method offers their customers the ability to pick which actual bed is booked …
so
bookingid | 23
bookingDate | 2008-03-03
bedsbooked1 | 5 [bed number 5, next to the toilet ;) ]
bedsbooked2 | 0
Whilst keeping an eye on these 2 issues:
What is likely to be the most frequent database event? selecting or updating? and what effect will my decisions make?
How complicated will the joins be?
Neither of them are show stoppers, because optimizing your queries before you start is not the right way to design things - but still, bear it in mind, and there is a fantastic sql forum here which will get you out of most of the holes you might dig yourself into.
Answer your first question first though:
I now need to work out the number of nights between the two dates and also submit all dates between the start and end to my database.
So, when Mrs Bloggs tries to book 14 nights, 4 beds in room1, from 2nd March to 16th March - how do you flag up and deal with what is quite a small problem which could cause your client to lose the hefty booking?