Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C8DA99FB231 for ; Tue, 27 Mar 2007 10:36:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 73329-09 for ; Tue, 27 Mar 2007 10:36:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by postgresql.org (Postfix) with ESMTP id 4BE639FA2C2 for ; Tue, 27 Mar 2007 10:36:45 -0300 (ADT) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), id 0MKwtQ-1HWBqs3JcM-0006PS; Tue, 27 Mar 2007 15:36:43 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1HWBqs-0005WU-00 for pgsql-sql@postgresql.org; Tue, 27 Mar 2007 15:36:42 +0200 Date: Tue, 27 Mar 2007 15:36:42 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: Foreign Unique Constraint Message-ID: <20070327133642.GB19137@a-kretschmer.de> References: <4f4c2a010703270621h5137a4e5rb515a9be9034a543@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4f4c2a010703270621h5137a4e5rb515a9be9034a543@mail.gmail.com> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1+HjS3enLWi8Hlnp8VdQY3giSf+aeSg+l8xDjw Rh4dLVrvvFBF8eeois20Dge+xne1hWvRycAWCrvSrCm0Wr6vBY MeuT6ASAnyQQu/UQ2Nw3mPMXuKAJL9W X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/313 X-Sequence-Number: 27951 am Tue, dem 27.03.2007, um 9:21:44 -0400 mailte Jon Horsman folgendes: > I was wondering if someone could help point me in the right direction > w.r.t. foreign unique constraints. I'm working on a legacy database > and have a new requirement and am not sure how to do it. > > I have something like this > > create table table1 ( > id SERIAL PRIMARY KEY > extension UNIQUE, I can't find anything about this syntax in the docs... > > 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. I think, you should write a TRIGGER for this. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net