I am confused whether cross or Cartesian product in relational algebra same as JOINS in SQL. If not, What is the equivalent of cross-product in SQL?
Asked
Active
Viewed 366 times
0
-
2A `CROSS JOIN` is a Cartesian product – HoneyBadger Nov 04 '20 at 14:34
-
There is no relational or SQL "cross product". There is cross join & (so-called Cartesian) product. – philipxy Nov 04 '20 at 15:43
-
Duplicate of [What is the difference between Cartesian product and cross join?](https://stackoverflow.com/q/11861417/3404097) (Obviously,) This is a faq. Please before considering posting read your textbook and/or manual & google any error message or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names & site:stackoverflow.com & tags; read many answers. Reflect your research. See [ask] & the voting arrow mouseover texts. If you post a question, use one phrasing as title. Also: How are you stuck determining the answer? [ask] – philipxy Nov 04 '20 at 15:46
1 Answers
-1
A cross join
produces a Cartesian product.
However, "join" in SQL is broader than a Cartesian product, or subset there of, because SQL supports outer joins.

Gordon Linoff
- 1,242,037
- 58
- 646
- 786
-
Thanks for the answer. Also, Do natural join and cartesian product give the same result in Relational Algebra? – Vishal Kamlapure Nov 04 '20 at 15:12
-
This answer is misleading. "For the Cartesian product to be defined, the two relations involved must have disjoint headers" says wikipedia on RA. If that condition doesn't hold, a `cross join` produces an error. (Under usual caveats about which dialect of RA. Also note the tech term is 'heading', not 'header'. A 'header' is something a file in a file system might have.) – AntC Nov 05 '20 at 08:55
-
1To answer @Vishal's follow-up: If the two relations involved have disjoint headings, then the natural join degenerates to a Cartesian product. If headings not disjoint, natural join is still well-defined, but Cartesian product isn't. (Under usual caveats about which dialect of RA.) – AntC Nov 05 '20 at 08:58
-
-
@VishalKamlapure . . . Is there a reason you unaccepted this answer? – Gordon Linoff Nov 05 '20 at 11:57