Re: check constraint on multiple tables?

Поиск
Список
Период
Сортировка
От Little, Douglas
Тема Re: check constraint on multiple tables?
Дата
Msg-id A434C531E37AD442815608A769550D805941EBA95F@EGEXCMB01.oww.root.lcl
обсуждение исходный текст
Ответ на check constraint on multiple tables?  (Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>)
Ответы Re: check constraint on multiple tables?  (Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>)
Список pgsql-sql
Hello,

I would have designed as ship > cabin  (PK of ship_id, Cabin_id)
And a separate chain of cabin_type > cabin_category > cabin

Type, and category are group classifiers and shouldn't be used to define the uniqueness of a cabin.

Take an example where the cabin category and type are defined globally for the entire fleet. Currently you'll have to
duplicatethe type, category defintions for each ship.  

Doug


-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Louis-David Mitterrand
Sent: Wednesday, March 03, 2010 9:02 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] check constraint on multiple tables?

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,

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


В списке pgsql-sql по дате отправления:

Предыдущее
От: Richard Broersma
Дата:
Сообщение: Re: check constraint on multiple tables?
Следующее
От: "Oliveiros"
Дата:
Сообщение: Re: check constraint on multiple tables?