On Wed, Mar 03, 2010 at 07:14:29AM -0800, Richard Broersma wrote:
> On Wed, Mar 3, 2010 at 7:02 AM, Louis-David Mitterrand
> <vindex+lists-pgsql-sql@apartia.org> wrote:
>
>
> > What is the best solution? Adding an id_ship to 'cabin'? Or check'ing
> > with a join down to 'ship'? (if possible).
>
> Can you post simplified table definitions for the relations involved?
Sure, here they are:
CREATE TABLE ship ( id_ship serial primary key, ship_name text unique not null
);
CREATE TABLE cabin_type ( id_cabin_type serial primary key, id_ship integer references ship, cabin_type_name
text, cabin_type_code text,unique(cabin_type_code, id_ship)
);
CREATE TABLE cabin_category ( id_cabin_category serial primary key, id_cabin_type integer references cabin_type,
cabin_cat_nametext, cabin_cat_code text,unique(cabin_cat_code, id_cabin_type)
);
CREATE TABLE cabin ( id_cabin serial primary key, id_cabin_category integer references cabin_category,
cabin_numberinteger not null,unique(id_cabin_category, cabin_number)
);