From: | Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: check constraint on multiple tables? |
Date: | 2010-03-03 15:19:00 |
Message-ID: | 20100303151900.GA19735@apartia.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)apartia(dot)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_name text,
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_number integer not null,
unique(id_cabin_category, cabin_number)
);
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Broersma | 2010-03-03 15:29:22 | Re: check constraint on multiple tables? |
Previous Message | Richard Broersma | 2010-03-03 15:14:29 | Re: check constraint on multiple tables? |