Re: self referenced table ?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: BRINER Cedric <work(at)infomaniak(dot)ch>
Cc: postgres <pgsql-general(at)postgresql(dot)org>
Subject: Re: self referenced table ?
Date: 2004-03-19 15:00:59
Message-ID: 20040319065834.P75424@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Fri, 19 Mar 2004, BRINER Cedric wrote:

> CREATE TABLE test (key1 int, key2 int , primary key (key1,key2), parent
> <?kind of data type?> constraint parent references test );

Foreign keys must reference a unique value. If the only uniqueness
constraint is (key1, key2) as above, then it requires two columns to do
the constraint (one holding the referenced key1 value, one holdign the
referenced key2 value) and a table level foreign key constraint or you
need something like a serial key added to the table.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-03-19 15:01:57 Re: "People near me" query
Previous Message Pierre Didelon 2004-03-19 14:58:18 unsigned types, binary op. and cast pb