Re: DDL problems: Referential issue? - Mailing list pgsql-sql

From Leif Biberg Kristensen
Subject Re: DDL problems: Referential issue?
Date
Msg-id 200911041936.15292.leif@solumslekt.org
Whole thread Raw
In response to Re: DDL problems: Referential issue?  (Scott Marlowe <scott.marlowe@gmail.com>)
Responses Re: DDL problems: Referential issue?  (Scott Marlowe <scott.marlowe@gmail.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: DDL problems: Referential issue?
Next
From: Scott Marlowe
Date:
Subject: Re: DDL problems: Referential issue?