pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Jungwirth <pj@illuminatedcomputing.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-general@lists.postgresql.org
Subject: Re: Primary key gist index?
Date: Wed, 14 Mar 2018 12:08:56 -0700
Message-ID: <f58a4a58-b9c8-381c-6a5d-50f10a8284a5@illuminatedcomputing.com> (raw)
In-Reply-To: <9545.1521053096@sss.pgh.pa.us>
References: <CAMa1XUiQDM2n5EHPir_ECoTjdA=kEDu1u_p=zMUxzdkkJpgmhw@mail.gmail.com>
	<420e0752-1197-c1be-c50c-eba42f35ad99@illuminatedcomputing.com>
	<9545.1521053096@sss.pgh.pa.us>

On 03/14/2018 11:44 AM, Tom Lane wrote:> Also, as you mention, 
extrapolating behavior that's not really equality
> to situations like foreign keys gets pretty interesting pretty fast.
> An exclusion constraint using && might ensure that no two values in the
> column are identical, but it would not be enough to ensure that a proposed
> FK row can't && with more than one PK row.  So what then?

This is (perhaps) a digression from the OP's question, but in temporal 
databases it is fine if the child record's as_of_time overlaps with 
multiple records from the parent table. In fact that would be pretty 
normal. What's required is that the child's as_of_time is completely 
covered by the "sum" of the as_of_times of the parent records with a 
matching ID. For example:

houses
id  as_of_time                appraisal
1   [2016-01-01, 2017-01-01)  $200k
1   [2017-01-01, 2018-01-01)  $230k

rooms
id  as_of_time                house_id
1   [2016-01-01, 2018-01-01)  1

If you had a "temporal foreign key" from rooms to houses, that example 
should be valid. I understand that's not possible today with normal 
foreign keys, and maybe it's too specific to be desirable as a 
general-purpose feature, but that's what the github extension I linked 
to tries to offer.

-- 
Paul              ~{:-)
pj@illuminatedcomputing.com




view thread (9+ messages)  latest in thread

Message-ID: <f58a4a58-b9c8-381c-6a5d-50f10a8284a5@illuminatedcomputing.com>
Permalink:  ../f58a4a58-b9c8-381c-6a5d-50f10a8284a5@illuminatedcomputing.com/
Also on:    postgresql.org/message-id/f58a4a58-b9c8-381c-6a5d-50f10a8284a5@illuminatedcomputing.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: pj@illuminatedcomputing.com, tgl@sss.pgh.pa.us
  Subject: Re: Primary key gist index?
  In-Reply-To: <f58a4a58-b9c8-381c-6a5d-50f10a8284a5@illuminatedcomputing.com>
  References: <CAMa1XUiQDM2n5EHPir_ECoTjdA=kEDu1u_p=zMUxzdkkJpgmhw@mail.gmail.com> <420e0752-1197-c1be-c50c-eba42f35ad99@illuminatedcomputing.com> <9545.1521053096@sss.pgh.pa.us> <f58a4a58-b9c8-381c-6a5d-50f10a8284a5@illuminatedcomputing.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox