Cross-Product JOIN?

2023-05-24 Thread Atomic_Sheep
Hi, I'm reading the documentation and I'm trying to wrap my head
around this statement:

"Finally, NATURAL is a shorthand form of USING: it forms a USING list
consisting of all column
names that appear in both input tables. As with USING, these columns
appear only once in the
output table. If there are no common column names, NATURAL JOIN
behaves like JOIN ...
ON TRUE, producing a cross-product join."

Did it mean cartesian product and not cross-product?




Re: Cross-Product JOIN?

2023-05-24 Thread Erik Wienhold
> On 24/05/2023 10:22 CEST Atomic_Sheep  wrote:
>
> "Finally, NATURAL is a shorthand form of USING: it forms a USING list
> consisting of all column
> names that appear in both input tables. As with USING, these columns
> appear only once in the
> output table. If there are no common column names, NATURAL JOIN
> behaves like JOIN ...
> ON TRUE, producing a cross-product join."
>
> Did it mean cartesian product and not cross-product?

Cross product means cartesian product in this context.  So technically correct.
Personally, I think it should read cartesian product because cross product is an
overloaded term and cartesian product is used more often in the documentation
overall.

But the same page [0] also uses cross product when talking about grouping sets.

The source code uses cross product in a couple of comments, though.

[0] https://www.postgresql.org/docs/15/queries-table-expressions.html

--
Erik




Re: Cross-Product JOIN?

2023-05-24 Thread Erik Wienhold
> On 24/05/2023 15:46 CEST Erik Wienhold  wrote:
>
> Personally, I think it should read cartesian product because cross product is
> an overloaded term and cartesian product is used more often in the 
> documentation
> overall.
>
> But the same page [0] also uses cross product when talking about grouping 
> sets.
>
> [0] https://www.postgresql.org/docs/15/queries-table-expressions.html

Here's a patch that fixes those two places.

--
ErikFrom b23bd267ac9c4e79efb472c08dc35737bc8e9ca6 Mon Sep 17 00:00:00 2001
From: Erik Wienhold 
Date: Wed, 24 May 2023 20:21:47 +0200
Subject: [PATCH] Use Cartesian product consistently in docs

Fixes two places in the docs that use "cross product" instead of the
more common "Cartesian product", used throughout the rest of the docs.
For the NATURAL JOIN without common column names it is easiest to refer
to CROSS JOIN which is already described as the Cartesian product.
---
 doc/src/sgml/queries.sgml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml
index 6986ec5c92..a75a241d62 100644
--- a/doc/src/sgml/queries.sgml
+++ b/doc/src/sgml/queries.sgml
@@ -392,7 +392,7 @@ FROM table_reference , table_r
 input tables.  As with USING, these columns appear
 only once in the output table.  If there are no common
 column names, NATURAL JOIN behaves like
-JOIN ... ON TRUE, producing a cross-product join.
+CROSS JOIN.

 

@@ -1362,7 +1362,7 @@ GROUPING SETS (
 

 If multiple grouping items are specified in a single GROUP BY
-clause, then the final list of grouping sets is the cross product of the
+clause, then the final list of grouping sets is the Cartesian product of the
 individual items.  For example:
 
 GROUP BY a, CUBE (b, c), GROUPING SETS ((d), (e))
-- 
2.40.1



Re: Cross-Product JOIN?

2023-05-24 Thread Laurenz Albe
On Wed, 2023-05-24 at 21:10 +0200, Erik Wienhold wrote:
> > On 24/05/2023 15:46 CEST Erik Wienhold  wrote:
> > 
> > Personally, I think it should read cartesian product because cross product 
> > is
> > an overloaded term and cartesian product is used more often in the 
> > documentation
> > overall.
> > 
> > But the same page [0] also uses cross product when talking about grouping 
> > sets.
> > 
> > [0] https://www.postgresql.org/docs/15/queries-table-expressions.html
> 
> Here's a patch that fixes those two places.

+1

"Cross product" seems to be a misbegotten hybrid of "cross join" and
"Cartesian product".

Since we are talking about Cartesian products: is the term "Cartesian join"
used anywhere?

Yours,
Laurenz Albe