Re: DB Question | A hotel reservation scenario

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2009-08-18 at 19:15 +0430, Behzad wrote:
> Dear list,
> e-Greetings!
> 
> I'm faced with an interesting and challenging problem.
> 
> Consider a database, designed for a hotel.
> At any given time, each room has a different status: It's Busy or Reserved,
> or Free.
> 
> It's easy to retrieve number of Free rooms at the current time.
> But how can I count the number of rooms that were busy during the last week
> ?
> 
> I would appreciate if you take a brief moment of your time and share your
> opinion.
> 
> Thank you in advance,
> -b

Keep a table that lists all the rooms along with their current status

Keep another table that has these fields:
      * room_id (the id from above table)
      * status (enumerated value - 'busy','reserved')
      * start_date
      * end_date

Then you perform your query using a join of these two tables, within a
particular date range. I've left out 'free' from the second table
because there's no point updating the table for a period if a room is
not being used.

You could also have start_date and end_date as datetime fields, as every
hotel i've ever been in has a set time for check-in and another for
check-out.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux