Foreign key constraint for array-field?

From: "Dmitry Koterov" <dmitry(at)koterov(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Foreign key constraint for array-field?
Date: 2008-09-21 00:38:56
Message-ID: d7df81620809201738w625efb14o10f7af4d7d35806f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-09-21 00:56:57 Re: [patch] fix dblink security hole
Previous Message Joe Conway 2008-09-20 23:31:27 Re: [patch] fix dblink security hole