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

Re: foreign keys for array/period contains relationships

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: foreign keys for array/period contains relationships
Date: 2010-10-26 00:57:54
Message-ID: AANLkTi=1h3=pSB8JCKpsNaT5xt2Kq_QvFEnCrku1yhUT@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Mon, Oct 25, 2010 at 5:24 PM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> I think that's easier when the PK must contain the FK, because then you
> only need to lock one record. Even when you need to lock multiple
> records, it seems feasible, and is just an index lookup, right? Do you
> see a particular problem?

Well if you lock multiple records then it's not clear what operations
you should conflict with. Removing any one of them wouldn't actually
invalidate the foreign key reference unless you remove the last one.

I always assumed this was why we require the unique constraint at all.
Otherwise we could just do a sequential scan and lock all the matching
records. but we would be preventing someone from removing those
records even though removing just one wouldn't be breaking the
constraint.


-- 
greg

In response to

Responses

pgsql-hackers by date

Next:From: David E. WheelerDate: 2010-10-26 01:02:04
Subject: Re: Composite Types and Function Parameters
Previous:From: Robert HaasDate: 2010-10-26 00:38:20
Subject: Re: Range Types, discrete and/or continuous

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