Re: Arrays and foreign keys

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Kaare Rasmussen <kar(at)webline(dot)dk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Arrays and foreign keys
Date: 2000-08-10 16:52:18
Message-ID: Pine.BSF.4.10.10008100941010.64041-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 10 Aug 2000, Kaare Rasmussen wrote:

> > Well, the two types aren't the same (one is an integer the
> > other an integer array,) so I wouldn't expect it to work. Note:
>
> Eh, I could figure that out myself. What I'm asking for is if there is a way to
> combine arrays with foreign keys?

For what you want, maybe. Probably defining an equals operator to make
the two types comparable for equality would allow the constraint to work.

> I believe the answer for now is 'no', but did like to get it confirmed, and
> also draw attention to this if someone wants to make it.
>
> > * Make sure that types used in foreign key constraints
> > are comparable.
>
> And maybe
> * Add foreign key constraint for arrays

Actually, it would be:
* Change foreign key constraint for array -> element to mean element
in array,
since the constraints seem to work on arrays (make two integer
arrays and reference them and it seems to work in my two minute test).

The question is whether or not we want to extend the spec in this way.
It would probably be easy to do, but it's definately an extension, since
the spec says that the two things should be equal, and I don't generally
think of element in array as equality. And, what do we do if neither
the in operator nor equals is defined between array and element?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message G. Anthony Reina 2000-08-10 17:01:44 Input strings > 16 K?
Previous Message Jan Wieck 2000-08-10 16:25:18 Re: Arrays and foreign keys