Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 05579632CB9 for ; Wed, 3 Mar 2010 11:38:45 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40244-01 for ; Wed, 3 Mar 2010 15:38:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sargon.lncsa.com (mail.lncsa.com [213.215.28.11]) by mail.postgresql.org (Postfix) with ESMTP id 600DE632D36 for ; Wed, 3 Mar 2010 11:38:34 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id 7113D301E6EA for ; Wed, 3 Mar 2010 16:38:32 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lncsa.com Received: from sargon.lncsa.com ([127.0.0.1]) by localhost (sargon.lncsa.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gMPuxLeooLrI for ; Wed, 3 Mar 2010 16:38:32 +0100 (CET) Received: from zenon.apartia.fr (zenon.apartia.fr [10.0.3.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "zenon.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by sargon.lncsa.com (Postfix) with ESMTP id 50CB9301E6EC for ; Wed, 3 Mar 2010 16:38:32 +0100 (CET) Received: from galba.apartia.fr (galba.apartia.fr [10.0.3.119]) by zenon.apartia.fr (Postfix) with ESMTP id F1EC258A0DA2B for ; Wed, 3 Mar 2010 16:38:31 +0100 (CET) Received: by galba.apartia.fr (Postfix, from userid 1000) id D150C1D42C; Wed, 3 Mar 2010 16:38:31 +0100 (CET) Date: Wed, 3 Mar 2010 16:38:31 +0100 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: check constraint on multiple tables? Message-ID: <20100303153831.GA20503@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org References: <20100303150227.GA18661@apartia.fr> <396486431003030714s48b239e2ub8b58a49b9aa29e4@mail.gmail.com> <20100303151900.GA19735@apartia.fr> <396486431003030729x17f921bcr7ff439113a5644ab@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <396486431003030729x17f921bcr7ff439113a5644ab@mail.gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.11 tagged_above=-10 required=5 tests=BAYES_05=-1.11 X-Spam-Level: X-Archive-Number: 201003/16 X-Sequence-Number: 33723 On Wed, Mar 03, 2010 at 07:29:22AM -0800, Richard Broersma wrote: > On Wed, Mar 3, 2010 at 7:19 AM, Louis-David Mitterrand > wrote: > > > CREATE TABLE cabin_type ( > > > CREATE TABLE cabin_category ( > > > CREATE TABLE cabin ( > > I'm just curious about a few things. > > 1) What is the difference between a cabin_type and a cabin_category. A cabin_type is: large suite, junior suite, balcony cabin, interior, etc. A cabin_category is, for say a "balcony cabin", on which deck it is located (price increases as the deck is higher). > 2) Does each ship have an exclusive set of cabin_types that no other > ship can have? The table definitions imply that this is so. Each ship is different and has specific cabin types and categories. Of course there is some overlap between ships but I thought it simpler (or more elegant) to use that hierarchy. Maybe my schema is wrong? > I'm just guessing here since I don't really understand the > relationships involved in a ship's cabins. However, I would expect > that a cabin should be directly related to a ship. Each cabin is > defined by a category according the set in the cabin_category table. I could add an id_ship to 'cabin' but that would make two (potentialy conflicting) relations to 'ship'.