Please clarify what you mean by Cartesian product. My understanding is no joins
The term Cartesian derives from the name of the French mathematician and philosopher René Descartes. A major step in the development of mathematics was his introduction of a coordinate system for defining points on a Euclidean plane by the intersection of two straight axes. This unified algebra and geometry by enabling algebraic definitions and analyses to be applied to geometric shapes.
The Cartesian product of two sets comprises
all of the
ordered pairs of the elements of each set. Think of a chess board. The two sets have values A to H and 1 to 8 respectively. The ordered pairs are thus A1,A2,A3...H8. The Cartesian coordinates of any square on the board are defined by the intersection of the two axes, e.g. C4. This is one of the ordered pairs which comprise the Cartesian product of the sets. In relational terms we can think of this square being the
restriction of the Cartesian product to x=C AND y=4. Prior to the SQL97 standard this was how tables were joined, by including the JOIN criteria in the WHERE clause. However, this could not handle OUTER JOINs and the JOIN clause was introduced to allow these. I can remember at that time many SQL developers persisted in putting the JOIN criteria in the WHERE cause, particularly if other restrictions were being applied by criteria in the WHERE clause.
The use of the Cartesian product is particularly useful still where we have two sets where the full set of the ordered pairs is to be returned as a preliminary to further restriction. I had an interesting example of this some years ago when helping out a MEDEVAC unit who needed to generate check lists for medications carried on their aircraft. The Cartesian product of the Aircraft and Medications tables provided the starting point from which they could then elect which to carry on each aircraft.
Note that mathematically speaking the Cartesian product of two sets comprises the
ordered pairs of the elements of each set. Mathematics does allow for
unordered pairs, however, and often this is what will be returned when we include two tables in a query without a specific JOIN. I'm not aware of a term for all
unordered pairs, and we tend to use the term Cartesian product rather loosely to cover both.