From: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
To: pgsql-sql@postgresql.org
Subject: Re: check constraint on multiple tables?
Date: Wed, 3 Mar 2010 16:19:00 +0100
Message-ID: <20100303151900.GA19735@apartia.fr> (raw)
In-Reply-To: <396486431003030714s48b239e2ub8b58a49b9aa29e4@mail.gmail.com>
References: <20100303150227.GA18661@apartia.fr>
<396486431003030714s48b239e2ub8b58a49b9aa29e4@mail.gmail.com>
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_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)
);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: vindex+lists-pgsql-sql@apartia.org
Subject: Re: check constraint on multiple tables?
In-Reply-To: <20100303151900.GA19735@apartia.fr>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox