Re: How hard would a "path" operator be to implement in PostgreSQL - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: How hard would a "path" operator be to implement in PostgreSQL
Date
Msg-id 20120820190600.GC23758@svana.org
Whole thread Raw
In response to How hard would a "path" operator be to implement in PostgreSQL  (Chris Travers <chris.travers@gmail.com>)
Responses Re: How hard would a "path" operator be to implement in PostgreSQL  (Craig Ringer <ringerc@ringerc.id.au>)
List pgsql-general
On Sun, Aug 19, 2012 at 06:28:57PM -0700, Chris Travers wrote:
> In DB2 this might be done like:
>
> SELECT * FROM address WHERE address->country->short_name = 'US';
>
> I like DB2's approach better because there is no ambiguity between
> namespace resolution but I don't entirely like the way the refs work as
> separate from standard foreign keys.

I'm not sure I have an opinion on pushing ORM features to the database
layer, SQLAlchemy is doing a pretty good job for me already.

I just wanted to say that in the beginning I didn't understand
SQLAchemy's separation between foreign keys and relationships, but I
have since come to understand that a "relationship" is a far more
general concept than a foreign key.  There are many kinds of
relationships between entities in a database that can't be represented
by a foreign key, but can be by a general join condition.

A simple example might be "items in an order" which you could derive
from a foreign key, compared to "items in an order which have sales
tax" which is something more general.

So whatever the result of this discussion, don't just consider foreign
keys, think bigger.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
   -- Arthur Schopenhauer

Attachment

pgsql-general by date:

Previous
From: elliott
Date:
Subject: Re: Database Bloat
Next
From: John R Pierce
Date:
Subject: Re: Database Bloat