check constraint on multiple tables? - Mailing list pgsql-sql

From Louis-David Mitterrand
Subject check constraint on multiple tables?
Date
Msg-id 20100303150227.GA18661@apartia.fr
Whole thread Raw
Responses Re: check constraint on multiple tables?  (Richard Broersma <richard.broersma@gmail.com>)
Re: check constraint on multiple tables?  ("Little, Douglas" <DOUGLAS.LITTLE@orbitz.com>)
List pgsql-sql
Hi,

I've got this chain of tables:

ship --> (id_ship) --> cabin_type --> (id_cabin_type) --> cabin_category--> (id_cabin_category) --> cabin

The 'cabin' table has (cabin_number, id_cabin_category ref. cabin_category)

How can I guarantee unicity of cabin_number per ship?

For now I added a unique(cabin_number,id_cabin_category) but this does
not guarantee unicity for (cabin_number,ship.id_ship).

What is the best solution? Adding an id_ship to 'cabin'? Or check'ing
with a join down to 'ship'? (if possible).

Thanks,


pgsql-sql by date:

Previous
From: John
Date:
Subject: determine the curval() of a view
Next
From: Richard Broersma
Date:
Subject: Re: check constraint on multiple tables?