X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 818885E46BF for ; Wed, 18 Aug 2004 14:06:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64796-03 for ; Wed, 18 Aug 2004 17:06:34 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 3E8145E46DE for ; Wed, 18 Aug 2004 14:06:25 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6112672; Wed, 18 Aug 2004 10:07:50 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Jan Wieck Subject: Re: multi column foreign key for implicitly unique columns Date: Wed, 18 Aug 2004 10:05:13 -0700 User-Agent: KMail/1.4.3 Cc: Markus Bertheau , olly@lfix.co.uk, pgsql-sql@postgresql.org References: <1092734724.2627.4.camel@dicaprio.akademie1.de> <200408171945.15663.josh@agliodbs.com> <41235A90.1080300@Yahoo.com> In-Reply-To: <41235A90.1080300@Yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200408181005.13230.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/206 X-Sequence-Number: 18703 Jan, > In the case that a table constraint is a referential constraint, > the table is referred to as the referencing table. The referenced > columns of a referential constraint shall be the unique columns of > some unique constraint of the referenced table. Missed that one. Interesting. AFAIK, the uniqueness of referenced columns is NOT a requirement of Relaitonal Algebra. So why does SQL require it? Maybe I'll ask Joe Celko after he finishes moving to Austin. I have my own issue that forced me to use triggers. Given: table users ( name login PK status etc. ) table status ( status relation label definition PK status, relation ) the relationship is: users.status = status.status AND status.relation = 'users'; This is a mathematically definable constraint, but there is no way in standard SQL to create an FK for it. This is one of the places I point to whenever we have the "SQL is imperfectly relational" discussion. -- Josh Berkus Aglio Database Solutions San Francisco