Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 481E2633652 for ; Wed, 4 Nov 2009 16:03:43 -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 03083-04 for ; Wed, 4 Nov 2009 20:03:29 +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 87D6E633F51 for ; Wed, 4 Nov 2009 16:03:28 -0400 (AST) Received: by iwn16 with SMTP id 16so5014481iwn.29 for ; Wed, 04 Nov 2009 12:03:26 -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=DEagNsNc5WR1G00sST1wrbjIya/0RnR09ueotWNo/J8=; b=YssrSK7tV2S4e6a0Sw9sBBl00eNFjGh3kgUjp4X7MyermifeKVg4HuUcb9PTNdkjaw 9qQ9v21V7J2GlmKpevRuZ9rqMzXrzVcT+ok4jW9u7XCe/avR4DUIVYgtiX+UmmlUW2lk kUUmcJMeLhzM3VJCZ91/DQuuaP+sZDN5bvwR4= 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=inhXcUugzLtGz046LgS2pFTM+cPvT9afoUnWyEfVSl69Ju0fzJm2QaEdyemXdznIC9 1IsyyXQ3RI5rS/iejBA+0KXDtR4D1/fSsfOr7uoskzS3Ev7JsM3uqTyTvp/J00ITSwkU aEPiDRW5hhYejshpqBXNbuM8Rsnujjoc+toZ4= MIME-Version: 1.0 Received: by 10.231.25.29 with SMTP id x29mr5107865ibb.31.1257365006513; Wed, 04 Nov 2009 12:03:26 -0800 (PST) In-Reply-To: <200911041953.11714.leif@solumslekt.org> References: <200911041903.36563.leif@solumslekt.org> <200911041936.15292.leif@solumslekt.org> <200911041953.11714.leif@solumslekt.org> Date: Wed, 4 Nov 2009 13:03:26 -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/16 X-Sequence-Number: 33367 On Wed, Nov 4, 2009 at 11:53 AM, Leif Biberg Kristensen wrote: > On Wednesday 4. November 2009 19.37.41 Scott Marlowe wrote: >> On Wed, Nov 4, 2009 at 11:36 AM, Leif Biberg Kristensen >> wrote: >>> 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. >> >> Hard to say, but if you really need a PK, you can always create one late= r. > > This looks strange to me, but it works: > > pgslekt=3D> CREATE TABLE participant_notes ( > pgslekt(> =A0 =A0 person_fk =A0 INTEGER NOT NULL, > pgslekt(> =A0 =A0 event_fk =A0 =A0INTEGER NOT NULL, > pgslekt(> =A0 =A0 part_note =A0 TEXT, > pgslekt(> =A0 =A0 PRIMARY KEY (person_fk, event_fk), > pgslekt(> =A0 =A0 FOREIGN KEY (person_fk, event_fk) REFERENCES participan= ts > (person_fk, event_fk) > pgslekt(> ); > NOTICE: =A0CREATE TABLE / PRIMARY KEY will create implicit index > "participant_notes_pkey" for table "participant_notes" > CREATE TABLE Note that this will limit you to one record in your participant notes for each record in the participants table. If you need > 1 of those, then you could either create a serial and use that for a PK, or PK on person_fk, event_fk and part_not, assuming part_note doesn't get real big. If it does you can PK on something like event, person, and md5(part_note) or something along those lines.