Re: foreign keys for array/period contains relationships - Mailing list pgsql-hackers

From Greg Stark
Subject Re: foreign keys for array/period contains relationships
Date
Msg-id AANLkTi=1h3=pSB8JCKpsNaT5xt2Kq_QvFEnCrku1yhUT@mail.gmail.com
Whole thread Raw
In response to Re: foreign keys for array/period contains relationships  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: foreign keys for array/period contains relationships
Re: foreign keys for array/period contains relationships
List pgsql-hackers
On Mon, Oct 25, 2010 at 5:24 PM, Jeff Davis <pgsql@j-davis.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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Range Types, discrete and/or continuous
Next
From: "David E. Wheeler"
Date:
Subject: Re: Composite Types and Function Parameters