What is a Cartesian Join?

First, it is helpful to understand how databases store data. They use tables, with rows and columns. Each row is a unique record, containing the same types of data, each stored in a column. For example, a table of customer data might contain columns for the first name, the last name, and a customer ID (unique to each customer, to help separate two John Smiths, for example). In that table, then, when a new customer is added to the database, a new row is added with a new ID, and the first and last name in the appropriate column.

Next, it is useful to know that data can be retrieved from the database using something called Structured Query Language, or SQL (see-kwul) for short. Different types of databases (Oracle, Teradata, SQL Server, etc.) each have their own individual SQL syntax, but they are generally similar.

All forms of SQL allow you to pull data from the table(s) of a database into a set of results, and they all allow you to JOIN more than one table.

For example, in addition to the customer table mentioned above, there could also be a Customer Address table. That table could contain a column for address, one for city, one for state, one for zip, and an Address ID (unique number for each address). And, for the sake of keeping this simple, even though you would rarely, if ever, design a database this way, it would also contain the Customer ID of the customer whose address is in that record.

That way, you could write a query that selects the name information from the Customer table, and JOIN the Customer table to the Customer Address table, using some kind of syntax similar to this:

select * from customer, customer_address
where customer.cust_id = customer_address.cust_id

The (*) means return all records. The records are coming from the customer table and the customer_address table. So, each row returned will have all the columns from the customer table AND from the customer_address table: