table design

From: "hostel Nate " <nate1001(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: table design
Date: 2007-04-30 05:04:33
Message-ID: 4f0672b50704292204i5aa172d5ncc91c6fc1a4b8347@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

HI,

I am designing a reservation system booking system. I want to put as much
logic into the database as possible so it is independent from the
application. One of the constraints is that a room can not be overbooked. I
have tried some different ideas of how to do it.

The idea is that you have rooms that can be either reserved or can be booked
in with a guest. But, the rule is that no room can be booked by either a
reservation or a paid booking more than once.

One idea, break the bookings into reservations and paid guests. The issues I
had with that idea is that is was difficult to join the views and the
double-book functions were duplicated for two tables.

Two, add a booking table which must have either a reservation dependency id
or a booking dependency id. This seems to me the best way to handle the data
because it seems that bookings should be a table to themselves. But, the
triggers to enforce it get much more complex in this scheme.

Three, denormalize the tables into one. The triggers become very simple but
what the data means becomes convoluted and a new field has to be added to
denote what kind of booking it is. The field paid_from, paid_to is somewhat
of a lie if it is reservation.

Any thoughts one what would be the 'best' way to handle this situation would
be appreciated.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Phillip Smith 2007-04-30 05:18:17 Re: table design
Previous Message Andrew Jarcho 2007-04-29 19:39:27 Re: call stored function from ecpg w/cursor