Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 0DEEE632D02 for ; Wed, 3 Mar 2010 12:18:12 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 34921-07 for ; Wed, 3 Mar 2010 16:18:00 +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 AAF6C632B8A for ; Wed, 3 Mar 2010 12:18:00 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id C1612300E01C for ; Wed, 3 Mar 2010 17:17:59 +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 T-tQRpKOQ0cQ for ; Wed, 3 Mar 2010 17:17:59 +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 A135C300E35F for ; Wed, 3 Mar 2010 17:17:59 +0100 (CET) Received: from galba.apartia.fr (galba.apartia.fr [10.0.3.119]) by zenon.apartia.fr (Postfix) with ESMTP id 58DFC58A0DA2F for ; Wed, 3 Mar 2010 17:17:59 +0100 (CET) Received: by galba.apartia.fr (Postfix, from userid 1000) id 3F0191D42C; Wed, 3 Mar 2010 17:17:59 +0100 (CET) Date: Wed, 3 Mar 2010 17:17:59 +0100 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: check constraint on multiple tables? Message-ID: <20100303161759.GB22889@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> <20100303153831.GA20503@apartia.fr> <7B7DB40901C947B688FD3BAC874E762F@marktestcr.marktest.pt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7B7DB40901C947B688FD3BAC874E762F@marktestcr.marktest.pt> User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.989 tagged_above=-10 required=5 tests=AWL=-0.990, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201003/22 X-Sequence-Number: 33729 On Wed, Mar 03, 2010 at 04:05:43PM -0000, Oliveiros wrote: > > As your table names seem to imply, type and category are cabin's > characteristics , not ship characteristics. > Am I right? Yes and no :) - I'm scanning cruise line web sites with a spider to collect prices so I'm building cabin_type's and cabin_category's on the fly, - each ship class (a cruise line has several) has its own particular types (Celebrity Xpedition is the only one with "Xpedition suite" type, etc.) > As Richard pointed out, maybe you could add a relationship between > cabin and ship and drop the relationship between ship and > cabin_category you now have > Then you could add that uniqueness restriction. That's one option. > Also, the relationship between type and category is one to many ? Or > can it be many to many? Put other way, is this overlap between the > categories that belong to different "types" ? One cabin_type to many cabin_category's, for example: - "Sunset Veranda Stateroom" (type) can be on "Vista", "Panorama", etc. decks (category) with a different price, But it's true that there is some overlap in categories between different ships. > If the later applies, maybe > you could have cabin refer to both type and category tables and drop > the relation between type and category. > > The cabin table would then work as an associative table between > category and type. > > Ain't saying your schema is wrong, maybe you have strong reasons to > do that that way, that I am not realizin by now... You got me thinking about it. Thank you for your interesting comments.