Understanding the Cartesian Product

Conceptually speaking, the first step in processing a join is to form the Cartesian product of the tables—all the possible combinations of the rows from each of the tables. Once the system obtains the Cartesian product, it uses the columns in the SELECT list for the projection and the conditions in the WHERE clause for the selection to eliminate the rows that do not satisfy the join.

The Cartesian product is the matrix of all the possible combinations that could satisfy the join condition. If there is only one row in each table, there is only one possible combination. To show the product of two tables having one row each, we use data values of a, b in one table and c, d in the other, with the column names ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.