Re: Temporal foreign keys

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Matthias <nitrogenycs(at)googlemail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Temporal foreign keys
Date: 2012-03-17 09:58:07
Message-ID: CA+U5nMJG+G0SyoXnF6r1pkPhJGCwMGekFAXXUoAWXfMOasf8cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Feb 3, 2012 at 6:58 AM, Matthias <nitrogenycs(at)googlemail(dot)com> wrote:

> how can I implement temporal foreign keys with postgresql? Is writing
> triggers the only way to enforce temporal referential integrity
> currently?

I think you need to explain what you want slightly better.

My guess would be you want this

create table x (d daterange primary key);
create table y (e date references x (d));

which is a lookup to show that the date is within a valid date range.

But you may also want this...

create table x (id integer, d daterange, primary key(id, d));
create table y (id integer, xid integer, e date, foreign key (xid,
e) references x (id, d));

which is to locate the valid row within a temporal lookup table.

Neither is possible, as yet.

Or you might want something entirely different?

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-general by date

  From Date Subject
Next Message dennis jenkins 2012-03-17 15:46:00 Re: A 154 GB table swelled to 527 GB on the Slony slave. How to compact it?
Previous Message Alban Hertroys 2012-03-17 09:53:40 Re: A 154 GB table swelled to 527 GB on the Slony slave. How to compact it?