Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 92B59634540 for ; Wed, 4 Nov 2009 14:37:50 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 92084-10 for ; Wed, 4 Nov 2009 18:37:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iw0-f186.google.com (mail-iw0-f186.google.com [209.85.223.186]) by mail.postgresql.org (Postfix) with ESMTP id 30F936341CF for ; Wed, 4 Nov 2009 14:37:43 -0400 (AST) Received: by iwn16 with SMTP id 16so4950526iwn.29 for ; Wed, 04 Nov 2009 10:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=dFs2yp2kpO94hbAiKOKscZ95kIF6lWjU1FMS33zwnr4=; b=I5BInjQijXMVf24yNJaLx7Sl6xYB+HhEGAWkuwNkzV+spNAotqbHZappRG+lZWRkb5 Qe39pL7k8fpUAta9BOPlXxssIXeOsSFZZPcHcBy/gJoPuTSOfpXHRTOHyJ658Ls0Id3T aeTiZPX/k6XwKGEB1q31uHSfVKTAQny4GHFcE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=syQThVBsZhiZjjZSob4Y1SWUMjTVofRvCW1nb+ievmtcyLR/Itglc97oR7Cp872D74 xbmIuVdqF5z7KRxGIaRd/xr7f+5HLbt3AD/mL5hOwtXaRr4FipytELPCp75Q7p9ES5yw 7VolhqhIZjnGTE38WwdtCPuyfOOW7YL84tH8c= MIME-Version: 1.0 Received: by 10.231.6.153 with SMTP id 25mr2554919ibz.54.1257359861689; Wed, 04 Nov 2009 10:37:41 -0800 (PST) In-Reply-To: <200911041936.15292.leif@solumslekt.org> References: <200911041903.36563.leif@solumslekt.org> <200911041936.15292.leif@solumslekt.org> Date: Wed, 4 Nov 2009 11:37:41 -0700 Message-ID: Subject: Re: DDL problems: Referential issue? From: Scott Marlowe To: Leif Biberg Kristensen Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/14 X-Sequence-Number: 33365 On Wed, Nov 4, 2009 at 11:36 AM, Leif Biberg Kristensen wrote: > 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. =A0Being 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. =A0You 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=3D> CREATE TABLE participant_notes ( > pgslekt(> =A0 =A0 person_fk =A0 INTEGER, > pgslekt(> =A0 =A0 event_fk =A0 =A0INTEGER, > pgslekt(> =A0 =A0 part_note =A0 TEXT, > pgslekt(> =A0 =A0 FOREIGN KEY (person_fk, event_fk) REFERENCES participan= ts > (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 e= xpect > it to grow beyond maybe a few thousand rows. Hard to say, but if you really need a PK, you can always create one later.