Skip site navigation (1) Skip section navigation (2)

Re: Array values and foreign keys

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Pierre-Fr?d?ric Caillaud <lists(at)boutiquenumerique(dot)com>
Cc: Daniel Savard <dsavard(at)cids(dot)ca>, pgsql-general(at)postgresql(dot)org
Subject: Re: Array values and foreign keys
Date: 2004-10-27 18:01:46
Message-ID: 20041027180145.GA96686@winnie.fuhr.org (view raw or flat)
Thread:
Lists: 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/

In response to

pgsql-general by date

Next:From: Alvaro HerreraDate: 2004-10-27 18:08:39
Subject: Re: what could cause inserts getting queued up and db locking??
Previous:From: Alvaro HerreraDate: 2004-10-27 17:59:00
Subject: Re: page locking? too many btree indexes...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group