Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 078D09FB8E8 for ; Tue, 27 Mar 2007 12:58:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 66914-05 for ; Tue, 27 Mar 2007 12:58:45 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id EF3089FB726 for ; Tue, 27 Mar 2007 12:58:45 -0300 (ADT) Received: (qmail invoked by alias); 27 Mar 2007 15:58:44 -0000 Received: from xdsl-87-78-222-63.netcologne.de (EHLO colt.pezone.net) [87.78.222.63] by mail.gmx.net (mp033) with SMTP; 27 Mar 2007 17:58:44 +0200 X-Authenticated: #495269 X-Provags-ID: V01U2FsdGVkX19cUpIWowdc0kfwy1rGG9rI/w5OYzFCnl/ZHkHz2i N2tx2dI6paVig0 From: Peter Eisentraut To: pgsql-sql@postgresql.org Subject: Re: Foreign Unique Constraint Date: Tue, 27 Mar 2007 17:58:42 +0200 User-Agent: KMail/1.9.5 Cc: "Jon Horsman" References: <4f4c2a010703270621h5137a4e5rb515a9be9034a543@mail.gmail.com> In-Reply-To: <4f4c2a010703270621h5137a4e5rb515a9be9034a543@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200703271758.42413.peter_e@gmx.net> X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/320 X-Sequence-Number: 27958 Jon Horsman wrote: > Basically table 1 and table 2 both have the concept of an extension > that must be unique but the rest of the info in the tables are > different.  I need to ensure that if i add an entry to table 1 with > extension 1000 that it will fail if there is already an entry in > table2 with the same extension. Make a third table that contains all the extension and add two columns, one referencing table 1 and one referencing table 2, and then add a constraint that only one of the two can be not null. It's not very pretty, but you can use views to make the access simpler. -- Peter Eisentraut http://developer.postgresql.org/~petere/