pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
To: pgsql-sql@postgresql.org
Subject: check constraint on multiple tables?
Date: Wed, 3 Mar 2010 16:02:27 +0100
Message-ID: <20100303150227.GA18661@apartia.fr> (raw)

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,



view thread (21+ messages)  latest in thread

Message-ID: <20100303150227.GA18661@apartia.fr>
Permalink:  ../20100303150227.GA18661@apartia.fr/
Also on:    postgresql.org/message-id/20100303150227.GA18661@apartia.fr

 · 

reply

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: <20100303150227.GA18661@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