SQL Joins and Set Operations Quiz

Last Updated :
Discuss
Comments

Question 1

Given employees as the left table and departments as the right table, which JOIN type would return all employees including those without assigned departments?

  • INNER JOIN

  • LEFT JOIN

  • RIGHT JOIN

  • NATURAL JOIN

Question 2

In a SELF JOIN, why are table aliases mandatory?

  • To satisfy SQL syntax rules

  • To distinguish between the table's two instances

  • To improve query performance

  • To enable transaction control

Question 3

What is the result of A ∪ B if relation A has (1,2,3) and B has (3,4,5)?

  • (1,2,3,4,5)

  • (3)

  • (1,2,3,3,4,5)

  • (1,2,4,5)

Question 4

Which SQL query finds customers who have never placed an order using JOINs?

  • SELECT * FROM customers LEFT JOIN orders ON customers.id = orders.customer_id

  • SELECT * FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.customer_id IS NULL;

  • SELECT * FROM customers INNER JOIN orders ON customers.id = orders.customer_id;

  • SELECT * FROM customers RIGHT JOIN orders ON customers.id = orders.customer_id;

Question 5

For relations A(P,Q) and B(Q,R), which operation is valid?

  • A ∪ B

  • A ∩ B

  • A - B

  • None (not union-compatible)

Question 6

What does A ∩ B = ((A ∪ B) - (A - B)) - (B - A) demonstrate?

  • Intersection can be derived using union and difference

  • De Morgan's Law for sets

  • Commutativity of intersection

  • SQL optimization technique

Question 7

In a FULL JOIN between Orders and Customers, what do NULLs in the Customer columns indicate?

  • Orders without matching customers

  • Customers without orders

  • Corrupted data

  • Pending transactions

Question 8

Which relational algebra operation is equivalent to SQL's EXCEPT?

  • ∪ (Union)

  • ∩ (Intersection)

  • - (Minus)

  • × (Cartesian Product)

Question 9

What makes NATURAL JOIN different from INNER JOIN?

  • NATURAL JOIN uses USING clause

  • NATURAL JOIN automatically matches columns with the same name

  • NATURAL JOIN preserves NULL values

  • NATURAL JOIN requires explicit join conditions

Question 10

Given relations X(A,B) and Y(A,C), which query returns only matching rows based on column A?

  • SELECT * FROM X INNER JOIN Y ON X.A = Y.A;

  • SELECT * FROM X LEFT JOIN Y ON X.A = Y.A;

  • SELECT * FROM X RIGHT JOIN Y ON X.A = Y.A;

  • SELECT * FROM X NATURAL JOIN Y;

There are 10 questions to complete.

Take a part in the ongoing discussion