Re: foreign keys for array/period contains relationships

From: Rod Taylor <rod(dot)taylor(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: foreign keys for array/period contains relationships
Date: 2011-03-20 15:18:06
Message-ID: AANLkTikeVH3UFDSbdWA7R0_Oor3ssL_s8424_TbQxry3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 25, 2010 at 15:11, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> Example #4: PK is period, FK is timestamp. FK must be contained in some
> PK period.
>
> CREATE TABLE pk (a period PRIMARY KEY, ...);
>
> CREATE TABLE fk (x timestamp REFERENCES pk (a), ...);
>
> As above, we can probably arrange the operator knowledge to make these
> checks. But I think additionally, you'd need an exclusion constraint on
> the PK side to ensure nonoverlapping arrays/periods so that on
> update/delete restrict as well as cascading deletes work.
>

Additional interesting examples involve IP network containment using
> inet/cidr or ip4/ip4r. There, you'd probably need additional syntax to
> tell the system explicitly which operators to use.
>

There are a large number of use-cases for this type of foreign key with
geometry ( PostGIS ) types as well. Point references Area or Line, Area
references Area, etc.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message hom 2011-03-20 15:31:11 Re: I am confused after reading codes of PostgreSQL three week
Previous Message Yeb Havinga 2011-03-20 15:03:04 Re: Sync Rep and shutdown Re: Sync Rep v19