Multiple choice technology databases

To produce a meaningful result set without any cartesian products, what is the minimum number of conditions that should appear in the WHERE clause of a four-table join?

  1. 8

  2. 3

  3. 2

  4. 4

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To join N tables without Cartesian products, you need N-1 join conditions. For 4 tables, you need 3 conditions. Each condition links two tables together. With 3 conditions for 4 tables, you create a chain: T1-T2, T2-T3, T3-T4. Fewer than 3 conditions would leave some tables disconnected, creating Cartesian products between disconnected sets. The minimum is n-1 conditions to connect n tables.

AI explanation

To join four tables without producing a cartesian product, each table needs to be linked to at least one other table via a join condition. With n tables, you need at least n-1 join conditions to connect them all into a single chain (or tree) of relationships, so four tables require a minimum of 3 conditions. Fewer than that leaves at least one table unlinked, which forces an unintended cross join with the rest of the result set.