Explore essential SQL join types in SQLite with this quiz focusing on INNER JOIN, LEFT JOIN, and CROSS JOIN concepts. Deepen your understanding of join operations, their syntax, and practical differences in relational database queries.
Given two tables, Employees and Departments, an INNER JOIN on DepartmentID returns which of the following?
Explanation: An INNER JOIN only returns rows where the join condition is met in both tables, so only employees with a department are included. Selecting all rows from Employees regardless of match describes a LEFT JOIN. Returning all possible combinations matches a CROSS JOIN. Only showing records from Departments ignores Employees and is incorrect.
What is the key feature of a LEFT JOIN between tables A and B?
Explanation: A LEFT JOIN returns every row from the left table (A), adding data from the right table (B) where available, and null for unmatched cases. Only showing matches describes an INNER JOIN. Including all rows from table B would be a RIGHT JOIN, which SQLite does not natively support. Returning no rows on no match omits LEFT JOIN’s primary purpose.
Which SQLite JOIN is used to produce the Cartesian product of two tables, such as Products and Categories?
Explanation: A CROSS JOIN generates all possible combinations of rows between two tables, creating a Cartesian product. LEFT JOIN and INNER JOIN return rows based on matching conditions, not all combinations. RIGHT JOIN is not a standard SQLite join.
Which is the correct SQL keyword to perform an inner join in SQLite syntax?
Explanation: The syntax uses 'INNER JOIN' to combine rows based on a matching condition. 'INSIDE JOIN', 'OUTER JOIN', and 'BOTH JOIN' are not valid SQL terms for this purpose. The explicit 'INNER JOIN' clearly signals an inner join operation in queries.
If a LEFT JOIN is used on Customers and Orders but some customers have never placed an order, what will the Orders fields show for those customers?
Explanation: For customers without matching orders, the result of the LEFT JOIN shows NULL in the Orders columns. Zero values or empty strings are not assigned by default; these would need to be set explicitly in queries. Random data does not appear in standard join operations.
What is the result size of a CROSS JOIN between a table with 4 rows and another with 3 rows?
Explanation: CROSS JOIN combines every row from both tables, so 4 rows times 3 rows results in 12 rows. Seven rows, four rows, or three rows would only occur under different join types or with limited data.
Which SQL JOIN requires an explicit condition to match rows from both tables?
Explanation: An INNER JOIN requires a condition, such as ON columns, to match rows. CROSS JOIN does not use a condition and instead produces all combinations. FULL JOIN and MULTI JOIN are not native to SQLite, and neither is correct here.
Which JOIN type should you use to identify records in the left table that have no corresponding match in the right table?
Explanation: A LEFT JOIN, when combined with a condition checking for NULL on the right table, lets you find rows in the left table without matches. INNER JOIN only returns matches, SELF JOIN is not used for this purpose, and CROSS JOIN does not match based on conditions.
What SQLite JOIN keyword can you use when you want every row from table M to be paired with every row from table N, regardless of any matching values?
Explanation: CROSS JOIN pairs each row from one table with every row in another, ignoring column values. INNER JOIN and LEFT JOIN rely on conditions, while OUTER JOIN is not a recognized keyword in standard SQLite.
If you write 'SELECT * FROM Sellers, Products' in SQLite, which JOIN is being performed by default?
Explanation: Listing multiple tables without a join condition or using commas creates a CROSS JOIN, resulting in the Cartesian product. LEFT JOIN and RIGHT JOIN require explicit keywords. INNER JOIN needs a condition and is not the default here.