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 D07D25E46DF for ; Tue, 17 Aug 2004 12:12:20 -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 16671-09 for ; Tue, 17 Aug 2004 15:12:25 +0000 (GMT) Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) by svr1.postgresql.org (Postfix) with ESMTP id 3C6AA5E46F1 for ; Tue, 17 Aug 2004 12:12:16 -0300 (ADT) Received: from [62.165.4.166] (dicaprio.akademie1.de [62.165.4.166]) (authenticated) by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i7HFCFg11667; Tue, 17 Aug 2004 17:12:15 +0200 Subject: Re: multi column foreign key for implicitly unique columns From: Markus Bertheau To: Stephan Szabo Cc: Tom Lane , Richard Huxton , pgsql-sql@postgresql.org In-Reply-To: <20040817080425.U61699@megazone.bigpanda.com> References: <1092734724.2627.4.camel@dicaprio.akademie1.de> <4121D55D.1040105@archonet.com> <20040817072443.S60684@megazone.bigpanda.com> <4307.1092753995@sss.pgh.pa.us> <1092754658.2627.32.camel@dicaprio.akademie1.de> <20040817080425.U61699@megazone.bigpanda.com> Content-Type: text/plain; charset=UTF-8 Message-Id: <1092755530.2627.36.camel@dicaprio.akademie1.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 17 Aug 2004 17:12:11 +0200 Content-Transfer-Encoding: quoted-printable 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/173 X-Sequence-Number: 18670 =D0=92 =D0=92=D1=82=D1=80, 17.08.2004, =D0=B2 17:06, Stephan Szabo =D0=BF= =D0=B8=D1=88=D0=B5=D1=82: > On Tue, 17 Aug 2004, Markus Bertheau wrote: >=20 > > =D0=92 =D0=92=D1=82=D1=80, 17.08.2004, =D0=B2 16:46, Tom Lane =D0=BF=D0= =B8=D1=88=D0=B5=D1=82: > > > > > I think one reason for this is that otherwise it's not clear which > > > unique constraint the FK constraint depends on. Consider > > > > > > create table a (f1 int unique, f2 int unique); > > > > > > create table b (f1 int, f2 int, > > > foreign key (f1,f2) references a(f1,f2)); > > > > > > How would you decide which constraint to make the FK depend on? > > > > Either way, the semantics are the same, right? >=20 > Unfortunately, not in the case of dropping the chosen constraint. Can't you choose at fk check time rather than fk creation time? > Theoretically in that case, you'd probably have to extend the spec there > as well to say that you check any dependent objects again to see if they > would still be valid rather than dropping them (on cascade) or erroring > (on restrict). That also makes sense and is more efficient as I see it. Thanks --=20 Markus Bertheau