I was recently asked an interview question on a hypothetical web based booking system and how I would design the database schema to minimize duplication and maximize flexibility.
The use case is that a admin would enter the availability of a property into the system. There could be multiple time period set. For example, 1st of April 2009 to 14th of April 2009 and 3rd of July 2009 to 21st of July 2009.
A user is then only able to place a booking in the periods made available of equal or shorter periods.
How would you store this information in a database?
Would you use something as simple (really simplified) as;
AVAILABILITY(property_id, start_date, end_date);
BOOKING(property_id, start_date, end_date);
Could you then easily construct a web page that showed a calendar of availability with periods that have been booked blanked out. Would it be easy to build reports from this database schema? Is it as easy as it seems?