Re: [PATCH] Support for Array ELEMENT Foreign Keys - Mailing list pgsql-hackers

From Claudio Freire
Subject Re: [PATCH] Support for Array ELEMENT Foreign Keys
Date
Msg-id CAGTBQpYyu_m6X+Diy8TEtgjMJp_m_PAxaZKa2wcyyXNBpWY0sQ@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Support for Array ELEMENT Foreign Keys  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCH] Support for Array ELEMENT Foreign Keys
List pgsql-hackers
On Fri, Oct 19, 2012 at 5:48 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> It looks like we could support
>
>         CREATE TABLE t1 (c int[] REFERENCES BY ELEMENT t2);
>
> but (1) this doesn't seem terribly intelligible to me, and
> (2) I don't see how we modify that if we want to provide
> at-least-one-match semantics later.

What about something more generic?

CREATE TABLE <tname> ( <cname> <type> [(<expr>)] REFERENCES <t2name>
[(<t2expr>)] )

Meaning, if <expr> is missing, it's taken <expr> = <cname>, if not,
it's the result of that expression the one that references the target
table.

Sounds crazy, but with ALL() and ANY() it ought to support lots of subcases.



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: First draft of snapshot snapshot building design document
Next
From: Andres Freund
Date:
Subject: Re: [PATCH] Support for Array ELEMENT Foreign Keys