Foreign key constraint for array-field? - Mailing list pgsql-hackers

From Dmitry Koterov
Subject Foreign key constraint for array-field?
Date
Msg-id d7df81620809201738w625efb14o10f7af4d7d35806f@mail.gmail.com
Whole thread Raw
Responses Re: Foreign key constraint for array-field?  ("Merlin Moncure" <mmoncure@gmail.com>)
Re: Foreign key constraint for array-field?  (David Fetter <david@fetter.org>)
Re: Foreign key constraint for array-field?  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
Hello.

Is it possible to create a foreign key constraint for ALL elements of
an array field?

CREATE TABLE a(id INTEGER);
CREATE TABLE b(id INTEGER, a_ids INTEGER[]);

Field b.a_ids contains a list of ID's of "a" table. I want to ensure
that each element in b.a_ids exists in a in any time. Is it possible
to create an automatic foreign key?

According to http://www.postgresql.org/docs/current/static/catalog-pg-constraint.html
, seems to me it is possible if I create a custom entry in
pg_constraint with my custom conpfeqop, conppeqop and conffeqop
fields.

Am I right?


pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: [patch] fix dblink security hole
Next
From: Tom Lane
Date:
Subject: Re: [patch] fix dblink security hole