From: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
---|---|
To: | Leif Biberg Kristensen <leif(at)solumslekt(dot)org> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: DDL problems: Referential issue? |
Date: | 2009-11-04 18:37:41 |
Message-ID: | dcc563d10911041037p5fda84dv1c003c97c112cfc7@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, Nov 4, 2009 at 11:36 AM, Leif Biberg Kristensen
<leif(at)solumslekt(dot)org> wrote:
> 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.
Hard to say, but if you really need a PK, you can always create one later.
From | Date | Subject | |
---|---|---|---|
Next Message | Leif Biberg Kristensen | 2009-11-04 18:53:11 | Re: DDL problems: Referential issue? |
Previous Message | Leif Biberg Kristensen | 2009-11-04 18:36:15 | Re: DDL problems: Referential issue? |