pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Scott Marlowe <scott.marlowe@gmail.com>
To: Leif Biberg Kristensen <leif@solumslekt.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: DDL problems: Referential issue?
Date: Wed, 4 Nov 2009 13:25:53 -0700
Message-ID: <dcc563d10911041225j3d09c78fp2410ed99c7ba886e@mail.gmail.com> (raw)
In-Reply-To: <200911042114.32722.leif@solumslekt.org>
References: <200911041903.36563.leif@solumslekt.org>
	<200911041953.11714.leif@solumslekt.org>
	<dcc563d10911041203r61124e04gf22e7f22a8bbd09@mail.gmail.com>
	<200911042114.32722.leif@solumslekt.org>

On Wed, Nov 4, 2009 at 1:14 PM, Leif Biberg Kristensen
<leif@solumslekt.org> wrote:
> 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.

Exactly.  Note that null values i pgsql take up VERY little space, so
performance-wise one table is likely faster, but it's not gonna break
the bank to have two.



view thread (8+ messages)

Message-ID: <dcc563d10911041225j3d09c78fp2410ed99c7ba886e@mail.gmail.com>
Permalink:  ../dcc563d10911041225j3d09c78fp2410ed99c7ba886e@mail.gmail.com/
Also on:    postgresql.org/message-id/dcc563d10911041225j3d09c78fp2410ed99c7ba886e@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: scott.marlowe@gmail.com, leif@solumslekt.org
  Subject: Re: DDL problems: Referential issue?
  In-Reply-To: <dcc563d10911041225j3d09c78fp2410ed99c7ba886e@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox