Re: Idea: Avoid JOINs by using path expressions to follow FKs - Mailing list pgsql-hackers

From Joel Jacobson
Subject Re: Idea: Avoid JOINs by using path expressions to follow FKs
Date
Msg-id 3062a31b-c13a-4fa1-bc35-e9c88953d8b4@www.fastmail.com
Whole thread Raw
In response to Re: Idea: Avoid JOINs by using path expressions to follow FKs  (Vik Fearing <vik@postgresfriends.org>)
List pgsql-hackers
On Mon, Mar 29, 2021, at 16:17, Vik Fearing wrote:
If you write your schema like this, then it becomes standards compliant:
...
CREATE TABLE order_details (
    "order" REF(orders),
    product REF(products),
    quantity integer,
    PRIMARY KEY ("order", product)
);


And the query would be:

SELECT DISTINCT order_details."order"->customer->company_name
FROM order_details
WHERE order_details.product->product_name = 'Chocolade';


Postgres already supports most of that, but not all of it.

Thanks for making me aware of this.
I can see this is "4.9 Reference types" in ISO/IEC 9075-2:2016(E).

This looks awesome.

/Joel

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Rename of triggers for partitioned tables
Next
From: Tomas Vondra
Date:
Subject: Merging statistics from children instead of re-sampling everything