0
0
DBMS Theoryknowledge~20 mins

Cartesian product and joins in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Join Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Cartesian Product in SQL

What is the result of performing a Cartesian product (cross join) between two tables, each having 3 rows?

AA table with 6 rows
BA table with 9 rows
CA table with 3 rows
DA table with 0 rows
Attempts:
2 left
💡 Hint

Remember, Cartesian product pairs every row of the first table with every row of the second table.

📋 Factual
intermediate
2:00remaining
Identifying Join Types

Which type of join returns only the rows where there is a match in both joined tables?

AINNER JOIN
BFULL OUTER JOIN
CRIGHT JOIN
DLEFT JOIN
Attempts:
2 left
💡 Hint

This join excludes rows without matching keys in either table.

🚀 Application
advanced
2:00remaining
Predicting Output of a Join Query

Given two tables:
Table A has 2 rows with IDs 1 and 2.
Table B has 3 rows with IDs 2, 3, and 4.
What will be the number of rows returned by the query: SELECT * FROM A LEFT JOIN B ON A.ID = B.ID;?

A5 rows
B3 rows
C2 rows
D6 rows
Attempts:
2 left
💡 Hint

LEFT JOIN returns all rows from the left table, matching rows from the right, or NULL if no match.

🔍 Analysis
advanced
2:00remaining
Analyzing Join Result Differences

What is the main difference between INNER JOIN and FULL OUTER JOIN results?

AINNER JOIN returns all rows from both tables, FULL OUTER JOIN returns only matching rows
BINNER JOIN and FULL OUTER JOIN return the same results
CINNER JOIN returns rows with NULLs, FULL OUTER JOIN excludes NULLs
DINNER JOIN returns only matching rows, FULL OUTER JOIN returns all rows from both tables with NULLs where no match
Attempts:
2 left
💡 Hint

Think about how unmatched rows are handled in each join type.

Reasoning
expert
3:00remaining
Determining Result Size of Complex Join

Consider two tables:
- Table X has 4 rows.
- Table Y has 5 rows.
If you perform a CROSS JOIN between X and Y, then INNER JOIN the result with a third table Z having 3 rows on a condition that matches exactly 2 rows from the CROSS JOIN result per row in Z, how many rows will the final result have?

A6 rows
B60 rows
C20 rows
D12 rows
Attempts:
2 left
💡 Hint

Calculate the size of the CROSS JOIN first, then multiply by the matching rows per Z row.