Given the SQL: SELECT CUSTOMER_T.CUSTOMER_ID, ORDER_T.CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T, ORDER_T; — what type of join is produced when no join predicate is supplied?

Difficulty: Easy

Correct Answer: Cartesian join

Explanation:


Introduction / Context:
Joins combine rows from tables. When you list multiple tables in the FROM clause without a join condition, the database produces a Cartesian product. Recognizing this is essential to avoid explosive row counts and unintended results.



Given Data / Assumptions:

  • Two tables are listed: CUSTOMER_T and ORDER_T.
  • No WHERE or JOIN ... ON predicate is shown.
  • Columns NAME and ORDER_ID are selected, along with both CUSTOMER_ID columns.


Concept / Approach:
A Cartesian join multiplies each row of one table by every row of the other. If CUSTOMER_T has m rows and ORDER_T has n rows, the result has m * n rows. Without a join predicate, the DBMS cannot match rows semantically, so it returns all combinations.



Step-by-Step Solution:

Identify the absence of a join predicate (no ON/USING and no WHERE filter).Conclude that the operation is a Cartesian product.Select the option that names a Cartesian join.


Verification / Alternative check:
Add a WHERE clause (e.g., CUSTOMER_T.CUSTOMER_ID = ORDER_T.CUSTOMER_ID) and compare row counts; the Cartesian product with no predicate will be much larger.



Why Other Options Are Wrong:
Equi-join/Natural join require equality conditions.
Outer join returns unmatched rows padded with NULLs, which still requires a join condition.



Common Pitfalls:
Accidentally omitting join conditions in older implicit join syntax (comma-separated tables), leading to huge, slow queries.



Final Answer:
Cartesian join

More Questions from Advanced SQL

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion