Best unofficial Apache Server developers community |
|
I realize this question has been asked in various forms but I am struggling with its implementation into my application. Here are my table setup: home: home_id, booking_id, name, address, location, etc booking: booking_id, fromdate, todate I am trying to build a search that will return the homes availability. So if home "A" is not booked from "4/4/2011 - 4/10/2011" then it will return home "A" as the result. Thanks for your help.
posted via StackOverflow
|
|
 
|
It's not going to work unless you start with a normalized database - your current schema makes no sense - presumably a home can have multiple bookings - yet you appear to have booking_id as a foreign key in the home table referencing bookings - this should be the other way around (booking should reference home_id). Using the correct schema:
or
With an index on booking (start_time, end_time, home_id) it should be reasonably efficient. |
|
 
|
|