Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 0662C63265D for ; Wed, 4 Nov 2009 16:16:16 -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 31016-01 for ; Wed, 4 Nov 2009 20:16:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail46.e.nsc.no (mail46.e.nsc.no [193.213.115.46]) by mail.postgresql.org (Postfix) with ESMTP id 840A1634374 for ; Wed, 4 Nov 2009 16:14:36 -0400 (AST) Received: from balapapa.localnet (42.185.16.62.customer.cdi.no [62.16.185.42]) (authenticated bits=0) by mail46.nsc.no (8.14.3/8.14.3) with ESMTP id nA4KEXLB008143 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 4 Nov 2009 21:14:34 +0100 (MET) From: Leif Biberg Kristensen To: pgsql-sql@postgresql.org Subject: Re: DDL problems: Referential issue? Date: Wed, 4 Nov 2009 21:14:32 +0100 User-Agent: KMail/1.12.1 (Linux/2.6.27-gentoo-r10; KDE/4.3.1; i686; ; ) Cc: Scott Marlowe References: <200911041903.36563.leif@solumslekt.org> <200911041953.11714.leif@solumslekt.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200911042114.32722.leif@solumslekt.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=AWL=0.000, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/17 X-Sequence-Number: 33368 On Wednesday 4. November 2009 21.03.26 Scott Marlowe wrote: > On Wed, Nov 4, 2009 at 11:53 AM, Leif Biberg Kristensen > > This looks strange to me, but it works: > > > > pgslekt=> CREATE TABLE participant_notes ( > > pgslekt(> person_fk INTEGER NOT NULL, > > pgslekt(> event_fk INTEGER NOT NULL, > > pgslekt(> part_note TEXT, > > pgslekt(> PRIMARY KEY (person_fk, event_fk), > > pgslekt(> FOREIGN KEY (person_fk, event_fk) REFERENCES participants > > (person_fk, event_fk) > > pgslekt(> ); > > NOTICE: CREATE 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. That's exactly what I want :) For all practical purposes, the design is equivalent to adding a TEXT column to the participants table. But as I expect a very small number of notes compared to the number of rows in the participants table, I prefer to create a small extra table rather than having a large number of null values in the participants table. Performance-wise, it probably doesn't matter much. It's more a matter of taste. -- Leif Biberg Kristensen http://solumslekt.org