Re: [PATCH] Support for Array ELEMENT Foreign Keys
Claudio Freire <klaussfreire@gmail.com>
From: Claudio Freire <klaussfreire@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>, Andrew Dunstan <andrew@dunslane.net>, Marco Nenciarini <marco.nenciarini@2ndquadrant.it>, pgsql-hackers@postgresql.org
Date: 2012-10-19T20:55:50Z
Lists: 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.