check constraint on multiple tables?

From: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: check constraint on multiple tables?
Date: 2010-03-03 15:02:27
Message-ID: 20100303150227.GA18661@apartia.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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,

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma 2010-03-03 15:14:29 Re: check constraint on multiple tables?
Previous Message John 2010-03-02 15:35:42 determine the curval() of a view