Re: foreign keys for array/period contains relationships

Peter Eisentraut <peter_e@gmx.net>

From: Peter Eisentraut <peter_e@gmx.net>
To: Jeff Davis <pgsql@j-davis.com>
Cc: pgsql-hackers@postgresql.org
Date: 2010-10-26T17:25:24Z
Lists: pgsql-hackers
On mån, 2010-10-25 at 17:38 -0700, Jeff Davis wrote:
> > Implementing the foreign key side of this merely requires the system
> to
> > have some knowledge of the required "contains" operator, which it
> does
> > in the array case, and something can surely be arranged for the
> range
> > case.  The problem is you can't do cascading updates or deletes, but
> you
> > could do on update/delete restrict, which is still useful.
> 
> Why can't you do cascading updates/deletes?

Let's say you have

PK

1
2
3
4
5

FK

[1,2,3]
[3,4,5]
[4,4,4]

When you delete PK = 3, what do you  expect to happen?  OK, you might
decide to delete the first two rows from the FK table.  This might or
might not make sense in a particular case, but on delete cascade is an
option the user has to choose explicitly.  But I don't see what to do
about cascading an update when you, say, update PK 1 => 6.