pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Leif Biberg Kristensen <leif@solumslekt.org>
To: pgsql-sql@postgresql.org
Subject: Re: DDL problems: Referential issue?
Date: Wed, 4 Nov 2009 19:36:15 +0100
Message-ID: <200911041936.15292.leif@solumslekt.org> (raw)
In-Reply-To: <dcc563d10911041024s67a3c313w1ed90c415840c2f7@mail.gmail.com>
References: <200911041903.36563.leif@solumslekt.org>
	<dcc563d10911041024s67a3c313w1ed90c415840c2f7@mail.gmail.com>

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



view thread (8+ messages)  latest in thread

Message-ID: <200911041936.15292.leif@solumslekt.org>
Permalink:  ../200911041936.15292.leif@solumslekt.org/
Also on:    postgresql.org/message-id/200911041936.15292.leif@solumslekt.org

 · 

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: leif@solumslekt.org
  Subject: Re: DDL problems: Referential issue?
  In-Reply-To: <200911041936.15292.leif@solumslekt.org>

* 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