Re: Foreign Keys With Arrays - Mailing list pgsql-novice

From Andreas Seltenreich
Subject Re: Foreign Keys With Arrays
Date
Msg-id 87irrr8u9n.fsf@gate450.dyndns.org
Whole thread Raw
In response to Re: Foreign Keys With Arrays  (Andreas Seltenreich <andreas+pg@gate450.dyndns.org>)
List pgsql-novice
Andreas Seltenreich writes:

> Ketema Harris writes:
>
>> If I have a column that is of type int4[] (array of integers) is it possible
>> to require that each integer within that array is a foreign key?
>
> I'm afraid you'll have to define a custom check-constraint to do that.
>
> E.g.
>
[...]
> scratch=# create function valid_array(a int4[]) returns boolean as $$
[...]

...and of course you'll need the appropriate trigger function on the
referenced table to maintain referential integrity, but I hope the
example will get you going.

regards,
Andreas
--

pgsql-novice by date:

Previous
From: Andreas Seltenreich
Date:
Subject: Re: Foreign Keys With Arrays
Next
From: Srinivas Iyyer
Date:
Subject: Please comment on pgsql speed at handling 550,000 records