Re: First-class Polymorphic joins?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Guyren Howe <guyren(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: First-class Polymorphic joins?
Date: 2015-08-14 00:49:36
Message-ID: 55CD3B20.6040502@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 08/13/2015 05:23 PM, Guyren Howe wrote:
> It surprises me that no SQL database to my knowledge has polymorphic joins as a first-class feature.
>
> A polymorphic join is where a fk contains not just an id but an indicator of which table it refers to.

I am pretty sure it already does that:

http://www.postgresql.org/docs/9.4/interactive/sql-createtable.html

REFERENCES reftable [ ( refcolumn ) ]

So you could have a "tags" table, that can attach tags to any of a
variety of other tables. Rails handles this by including the table name
as a string.
>
> This seems a reasonable thing to want to do, and it seems that the database could handle it by combining the fields from the target tables in the result.
>
> I also think migrations ought to be a first-class feature…

So is this the push the ORM into the database day?

>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-08-14 00:58:29 Re: Foreign Keys as first class citizens at design time?
Previous Message Tatsuo Ishii 2015-08-14 00:47:59 Re: [BDR] vs pgpool-II v3