Re: Foreign key in composite values - Mailing list pgsql-general

From Tom Lane
Subject Re: Foreign key in composite values
Date
Msg-id 10727.1304692354@sss.pgh.pa.us
Whole thread Raw
In response to Foreign key in composite values  (Vincent De Groote <vdg.encelade@gmail.com>)
Responses Re: Foreign key in composite values  (David Johnston <polobo@yahoo.com>)
List pgsql-general
Vincent De Groote <vdg.encelade@gmail.com> writes:
> I have a composite type with 2 fields.  I would like to check that one
> of these fields exists in another table.
> Foreign keys on a composite field does not seem to be supported.

Works for me, in 8.4 and up.  Whether it's a good idea is a different
issue (I think it'll be pretty inefficient, compared to a multicolumn
primary/foreign key on native datatypes), but it works.

regression=# create type cx as (r float8, i float8);
CREATE TYPE
regression=# create table p (id cx primary key);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "p_pkey" for table "p"
CREATE TABLE
regression=# create table s (c cx references p);
CREATE TABLE

            regards, tom lane

pgsql-general by date:

Previous
From: Mason S
Date:
Subject: Re: dblink() from GridSQL
Next
From: Andrew Sullivan
Date:
Subject: Re: Bidirectional replication