Re: Array values and foreign keys - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Array values and foreign keys
Date
Msg-id 20041027180145.GA96686@winnie.fuhr.org
Whole thread Raw
In response to Re: Array values and foreign keys  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
List pgsql-general
On Wed, Oct 27, 2004 at 05:59:46PM +0200, Pierre-Fr?d?ric Caillaud wrote:
>
>     - add CHECK( test_array( yourcolumn )) in your table definition
>     - create function test_array which takes an array and looks if all
>     its  elements are in your table T2, I do something like comparing the
> length of  the array to SELECT count(1) FROM T2 WHERE key IN array

This provides only partial foreign key checking: depending on how
the application works, you might also need to ensure that updates
and deletes in T2 don't break the references in T1.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: page locking? too many btree indexes...
Next
From: Alvaro Herrera
Date:
Subject: Re: Newbie question about casting literals - oracle/postgres