SQL Database Relational Join Logic Quiz

SQL Database
0 Passed
0% acceptance

A 50-question quiz exploring join operations including inner joins, left joins, right joins, full joins, cross joins, and join conditions.

50 Questions
~100 minutes
1

Question 1

A company wants to list only employees who belong to a department. Which join returns only rows with matching department records?

A
INNER JOIN
B
LEFT JOIN
C
RIGHT JOIN
D
CROSS JOIN
2

Question 2

A retailer wants to show all products, even those without sales yet. Which join ensures products appear regardless of sales?

A
LEFT JOIN from products to sales
B
INNER JOIN between products and sales
C
RIGHT JOIN from products to sales
D
CROSS JOIN only
3

Question 3

A user checks which orders lack assigned customers because of missing customer IDs. Which join helps reveal orders without a match?

A
LEFT JOIN from orders to customers
B
INNER JOIN only
C
CROSS JOIN
D
SELF JOIN
4

Question 4

A student portal wants to show all students and all courses, even if some combinations have no enrollment. Which join captures all rows from both sides?

A
FULL OUTER JOIN
B
INNER JOIN
C
LEFT JOIN
D
CROSS JOIN
5

Question 5

A system lists employees and their managers from within the same table. What join technique compares rows of a table with itself?

A
Self join
B
CROSS JOIN
C
RIGHT JOIN
D
Hash join
6

Question 6

A product list is paired with every available color option to form combinations. Which join intentionally forms all possible row pairs?

A
CROSS JOIN
B
LEFT JOIN
C
INNER JOIN
D
RIGHT JOIN
7

Question 7

A report shows customers even if they have no orders, but only shows orders when they match a customer. Which join is at work?

A
LEFT JOIN customers → orders
B
INNER JOIN customers → orders
C
FULL JOIN customers → orders
D
CROSS JOIN
8

Question 8

A query compares student IDs from one table to matching records in another. Why is an ON condition required?

A
It defines how rows match between tables
B
It controls sorting always
C
It forces text conversion
D
It creates indexes automatically
9

Question 9

A developer notices NULL on the right side of a left join. What does this usually indicate?

A
A missing match in the right table
B
A failure in numeric conversion
C
A sorting error
D
A grouping mismatch
10

Question 10

In a comparison of right join and left join, which behavior uniquely belongs to right joins?

A
They preserve all rows from the right table
B
They preserve all rows from the left table
C
They remove unmatched rows from both sides
D
They generate a Cartesian product
11

Question 11

A dataset uses INNER JOIN when retrieving invoices and their customers. Why do unmatched invoices disappear from the result?

A
Inner joins only keep rows with matches on both sides
B
Inner joins convert missing values into zeros
C
Inner joins always sort data first
D
Inner joins duplicate rows automatically
12

Question 12

A store wants to show both customers with orders and customers without orders, while also showing orders without customers. Which join works?

A
FULL OUTER JOIN
B
LEFT JOIN
C
INNER JOIN
D
CROSS JOIN
13

Question 13

A manufacturer uses a CROSS JOIN to list all material and size combinations. Why might the resulting table be very large?

A
Cross joins multiply every row from one table with every row of the other
B
Cross joins remove duplicates
C
Cross joins collapse values into groups
D
Cross joins only pair numeric columns
14

Question 14

Why must columns used in join comparisons generally share compatible data types?

A
Join comparison requires values that can be matched meaningfully
B
Joins require identical columns always
C
Joins convert all types to text
D
Joins cannot use numeric fields
15

Question 15

A self join compares parent IDs to child IDs within one table. Why is table aliasing necessary?

A
It distinguishes the two references so they don't conflict
B
It forces grouping behavior
C
It sorts rows automatically
D
It hides NULL values
16

Question 16

Why might an inner join shrink the number of returned rows compared to the original tables?

A
Only matching pairs survive
B
Inner joins sort values
C
Inner joins repeat unmatched rows
D
Inner joins add filler rows
17

Question 17

A left join lists all customers and shows NULL for order details if none exist. Why is this helpful in reporting?

A
It highlights missing data while preserving full customer lists
B
It forces sorting automatically
C
It calculates totals
D
It ensures unique values
18

Question 18

A cross join produces a pattern where every supplier is paired with every region. What is this pattern called?

A
Cartesian product
B
Right-scatter table
C
Null matrix
D
Binary grouping
19

Question 19

A report shows suppliers with no products after a right join. Why?

A
Right joins preserve all rows from the right table
B
Right joins remove duplicates
C
Right joins enforce strict type matching
D
Right joins convert NULL to zeros
20

Question 20

A chain of joins connects employees → departments → locations. Why is join order important?

A
It determines which rows are preserved at each step
B
It controls column renaming
C
It enforces numeric sorting
D
It removes NULLs automatically
21

Question 21

A query uses FULL JOIN to list all rows from both tables. Why might some fields show NULL?

A
NULL fills gaps where no matching row exists
B
NULL denotes invalid join usage
C
NULL indicates numeric overflow
D
NULL replaces duplicates
22

Question 22

A developer uses JOIN without specifying an ON condition. Why might the query produce unexpected results?

A
The lack of conditions produces unintended row pairings
B
The join forces conversion to text
C
The join sorts results alphabetically
D
The join fails because ON is mandatory
23

Question 23

A query extracting customer orders uses a join condition on customer_id. Why must the values in customer_id be consistent?

A
Join behavior depends on matching key values across tables
B
Joins require identical column names
C
Joins always convert keys to strings
D
Joins enforce alphabetical ordering
24

Question 24

A financial system uses INNER JOIN to combine transactions with accounts. Why might unmatched transactions be purposely excluded?

A
Only validated, matched rows should appear in financial output
B
Inner joins improve storage efficiency
C
Inner joins remove duplicates automatically
D
Inner joins enforce numeric formatting
25

Question 25

Why is a CROSS JOIN useful when generating all possible pairings between two sets, such as time slots and rooms?

A
It constructs combinations without requiring matches
B
It verifies values automatically
C
It removes duplicate pairs
D
It collapses groups together
26

Question 26

What does this query show about orders and customers?

sql
SELECT o.id, c.name FROM orders o INNER JOIN customers c ON o.customer_id = c.id;
A
Only orders with matching customers
B
All customers even without orders
C
All orders regardless of customer match
D
Random row pairings
27

Question 27

This query keeps all customers even when order info is missing. What result appears?

sql
SELECT c.id, o.id FROM customers c LEFT JOIN orders o ON c.id = o.customer_id;
A
Customers without orders appear with NULL on the order side
B
Only customers with orders appear
C
Orders without customers appear
D
Duplicate customers are removed
28

Question 28

What does this right join preserve?

sql
SELECT p.name, r.region FROM products p RIGHT JOIN regions r ON p.region_id = r.id;
A
All regions regardless of matching products
B
All products regardless of region
C
Only matched rows
D
Only unmatched products
29

Question 29

This full join mixes employees and departments. What rows appear?

sql
SELECT e.name, d.name FROM employees e FULL JOIN departments d ON e.dept_id = d.id;
A
All employees and all departments, with NULL for missing matches
B
Only rows with perfect matches
C
Only departments without employees
D
Only employees without departments
30

Question 30

A cross join creates pairings between products and categories. What does the output look like?

sql
SELECT p.name, c.type FROM products p CROSS JOIN categories c;
A
Every product combined with every category
B
Only matched pairs
C
Only unpaired rows
D
Only unique categories
31

Question 31

What does this join reveal about book authors?

sql
SELECT b.title, a.name FROM books b INNER JOIN authors a ON b.author_id = a.id;
A
Books with valid matching authors
B
Books without authors
C
Authors without books
D
All authors regardless of matches
32

Question 32

Which rows survive this filtering left join?

sql
SELECT u.username, p.post FROM users u LEFT JOIN posts p ON u.id = p.user_id WHERE p.user_id IS NOT NULL;
A
Only users who have posts
B
All users with NULL posts included
C
Only users without posts
D
Random user combinations
33

Question 33

This join links orders and shipments. What happens when a shipment is missing?

sql
SELECT o.id, s.date FROM orders o LEFT JOIN shipments s ON o.id = s.order_id;
A
Orders without shipments show NULL for s.date
B
Orders without shipments are removed
C
Shipments without orders appear
D
All shipments show even without orders
34

Question 34

What output shape results from joining students to enrollments on student IDs?

sql
SELECT s.name, e.course_id FROM students s INNER JOIN enrollments e ON s.id = e.student_id;
A
Only students with matching enrollment records
B
All students
C
All courses fully
D
Only unmatched students
35

Question 35

A query finds missing matches with this structure. What rows appear?

sql
SELECT a.id, b.value FROM a LEFT JOIN b ON a.id = b.a_id WHERE b.a_id IS NULL;
A
Rows from A without matches in B
B
Rows with successful matches
C
All rows from B only
D
Every pairing between A and B
36

Question 36

What does this multi-join accomplish?

sql
SELECT e.name, d.name, l.city FROM employees e INNER JOIN departments d ON e.dept_id = d.id INNER JOIN locations l ON d.loc_id = l.id;
A
It connects employees to department and location details
B
It returns all employees without filtering
C
It shows only unmatched departments
D
It produces random combinations
37

Question 37

This join lists suppliers and their products. How are unmatched suppliers represented?

sql
SELECT s.name, p.name FROM suppliers s LEFT JOIN products p ON s.id = p.supplier_id;
A
Unmatched suppliers show NULL for product name
B
They do not appear at all
C
They list all products incorrectly
D
They duplicate product rows
38

Question 38

A cross join mixes all days with all shifts. What is the result size?

sql
SELECT d.day, s.shift FROM days d CROSS JOIN shifts s;
A
Row count equals days × shifts
B
Only common rows appear
C
Shifts without days vanish
D
All rows merge into one
39

Question 39

This join finds employees whose departments lack location records. What pattern is used?

sql
SELECT e.id FROM employees e LEFT JOIN departments d ON e.dept_id = d.id WHERE d.id IS NULL;
A
Unmatched left rows after left join
B
Matched rows only
C
Unmatched right rows
D
Cross join rows
40

Question 40

What does this grouped join output represent?

sql
SELECT c.country, COUNT(*) FROM customers c INNER JOIN orders o ON c.id = o.customer_id GROUP BY c.country;
A
Order count per country
B
All customers regardless of orders
C
Only unmatched customers
D
Random ordering
41

Question 41

Which rows appear after this join filters NULL matches?

sql
SELECT c.name FROM categories c LEFT JOIN items i ON c.id = i.cat_id WHERE i.cat_id IS NOT NULL;
A
Only categories with items
B
All categories with NULLs kept
C
Only categories without items
D
All categories regardless of match
42

Question 42

What is the effect of this join condition?

sql
SELECT p.name, b.title FROM publishers p INNER JOIN books b ON p.id = b.publisher_id;
A
Shows only publishers with books
B
Shows all publishers
C
Shows books without publishers
D
Shows unmatched rows only
43

Question 43

This full join connects customers and feedback. What rows are included?

sql
SELECT c.id, f.comment FROM customers c FULL JOIN feedback f ON c.id = f.customer_id;
A
All customers and all feedback entries
B
Customers only
C
Feedback only
D
Only matched customer-feedback rows
44

Question 44

This self join compares employees by manager. What does it show?

sql
SELECT e.name, m.name FROM employees e JOIN employees m ON e.manager_id = m.id;
A
Employees alongside their managers
B
Employees without filtering
C
Managers without employees
D
All rows in cross product
45

Question 45

This join helps detect orphan rows. What does it return?

sql
SELECT o.id FROM orders o LEFT JOIN customers c ON o.customer_id = c.id WHERE c.id IS NULL;
A
Orders without matching customers
B
Orders with customers
C
Customers without orders
D
All orders
46

Question 46

A join links countries and regions. How are unmatched countries represented?

sql
SELECT c.name, r.name FROM countries c LEFT JOIN regions r ON c.region_id = r.id;
A
Countries show with NULL regions when unmatched
B
They are removed from output
C
They pair with all regions
D
They join only with themselves
47

Question 47

This join enriches products with supplier data. What does the ON condition enforce?

sql
SELECT p.name, s.contact FROM products p INNER JOIN suppliers s ON p.supplier_id = s.id;
A
Only products with valid suppliers appear
B
All products appear
C
Only suppliers appear
D
Cross product only
48

Question 48

This join simulates a calendar expansion. What does it produce?

sql
SELECT d.date, s.slot FROM dates d CROSS JOIN slots s;
A
All possible date-slot combinations
B
Only filled slots
C
Only dates
D
Only slots
49

Question 49

This join keeps all products and adds brand info when available. What does it show?

sql
SELECT p.name, b.brand FROM products p LEFT JOIN brands b ON p.brand_id = b.id;
A
All products, showing NULL if no matching brand exists
B
Only matched products
C
Only brands
D
Product-brand combinations only when multiple brands exist
50

Question 50

A company links events to locations. What does this inner join produce?

sql
SELECT e.title, l.place FROM events e INNER JOIN locations l ON e.location_id = l.id;
A
Events that have valid location references
B
All events regardless of location
C
Locations without events
D
Cross-product rows

QUIZZES IN SQL Database