Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5A2A06366D2 for ; Wed, 4 Nov 2009 14:36:30 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 15488-05 for ; Wed, 4 Nov 2009 18:36:17 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail48.e.nsc.no (mail48.e.nsc.no [193.213.115.48]) by mail.postgresql.org (Postfix) with ESMTP id 4064B63666A for ; Wed, 4 Nov 2009 14:36:17 -0400 (AST) Received: from balapapa.localnet (42.185.16.62.customer.cdi.no [62.16.185.42]) (authenticated bits=0) by mail48.nsc.no (8.14.3/8.14.3) with ESMTP id nA4IaFsG002252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 4 Nov 2009 19:36:16 +0100 (MET) From: Leif Biberg Kristensen To: pgsql-sql@postgresql.org Subject: Re: DDL problems: Referential issue? Date: Wed, 4 Nov 2009 19:36:15 +0100 User-Agent: KMail/1.12.1 (Linux/2.6.27-gentoo-r10; KDE/4.3.1; i686; ; ) References: <200911041903.36563.leif@solumslekt.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200911041936.15292.leif@solumslekt.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/13 X-Sequence-Number: 33364 On Wednesday 4. November 2009 19.24.29 Scott Marlowe wrote: > You're referencing a single column, which does not have a unique key > on it. Being part of a two column unique PK index doesn't count, as > you could have an entry where one column or the other repeats on its > own while the other column changes. You might want the syntax: > > FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn > [, ... ] ) > > where you FK a pair of columns to a pair of other columns. Thank you very much! pgslekt=> CREATE TABLE participant_notes ( pgslekt(> person_fk INTEGER, pgslekt(> event_fk INTEGER, pgslekt(> part_note TEXT, pgslekt(> FOREIGN KEY (person_fk, event_fk) REFERENCES participants (person_fk, event_fk) pgslekt(> ); CREATE TABLE I'd missed that particular syntax. This table is now without a primary key, but is that a problem? I don't expect it to grow beyond maybe a few thousand rows. -- Leif Biberg Kristensen http://solumslekt.org