Saturday, September 20, 2008

[HACKERS] Foreign key constraint for array-field?

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?

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

No comments: