Chapter 4 — Quiz
13 questions. Answers and explanations at the bottom.
Multiple choice
Q1. Relational selection (σ) corresponds to which SQL clause?
- A) The SELECT list
- B) WHERE
- C) JOIN
- D) ORDER BY
Q2. Relational projection (π) corresponds to:
- A) WHERE
- B) The SELECT list (the columns chosen)
- C) GROUP BY
- D) LIMIT
Q3. A join (⋈) is equivalent to: - A) A projection followed by a selection - B) A Cartesian product followed by a selection on the matching condition - C) A union of two tables - D) A rename
Q4. If customers has 12 rows and orders has 15, customers CROSS JOIN orders returns:
- A) 15 rows
- B) 12 rows
- C) 27 rows
- D) 180 rows
Q5. "Closure" in relational algebra means: - A) Queries always terminate - B) Every operation takes relations as input and produces a relation as output - C) Tables are locked during queries - D) Duplicate rows are removed
Q6. Which property makes subqueries, CTEs, and views possible? - A) Three-valued logic - B) Closure (relations in, relations out) - C) Referential integrity - D) Bag semantics
Q7. "Customers who have never placed an order" is naturally expressed with:
- A) Union (∪)
- B) Intersection (∩)
- C) Difference (−) / EXCEPT
- D) Cartesian product (×)
Q8. SQL's SELECT list performs which algebra operation?
- A) Selection (σ)
- B) Projection (π)
- C) Join (⋈)
- D) Rename (ρ)
Q9. "Pushing selection down" means: - A) Sorting results before returning them - B) Filtering rows before an expensive join rather than after - C) Selecting fewer columns - D) Pushing data to disk
Q10. SQL operates on _ by default, while pure relational algebra operates on _. - A) sets / bags - B) bags (multisets) / sets - C) lists / sets - D) trees / graphs
Q11. Which removes duplicate rows?
- A) UNION ALL
- B) UNION
- C) CROSS JOIN
- D) Plain SELECT col
True/False
Q12. SQL's keyword SELECT performs relational selection (choosing rows). (True / False)
Q13. Two equivalent relational-algebra expressions always return the same relation, even if one is faster to compute. (True / False)
---
Answer key
Q1 — B. Selection (σ) filters rows → WHERE.
Q2 — B. Projection (π) chooses columns → the SELECT list.
Q3 — B. Join = Cartesian product + selection on the join condition. This is why a missing condition yields a full product.
Q4 — D. 12 × 15 = 180. Every pairing, most meaningless — which is why you add a join condition.
Q5 — B. Closure: relations in, relations out. The result of any operation is itself a relation.
Q6 — B. Closure. Because a query returns a relation, you can query that — subqueries, CTEs, views.
Q7 — C. Difference: (all customers) − (customers who ordered) → EXCEPT (or an anti-join).
Q8 — B. Projection. (The name "SELECT" is a false friend — it's π, not σ.)
Q9 — B. Filter early, before the join, so the join processes fewer rows. A key optimizer rewrite.
Q10 — B. SQL = bags (duplicates allowed); pure algebra = sets (no duplicates).
Q11 — B. UNION dedupes; UNION ALL keeps duplicates (and is faster); CROSS JOIN and plain SELECT col keep duplicates.
Q12 — False. SQL's SELECT list is projection (π). Relational selection (σ) is the WHERE clause.
Q13 — True. Equivalence means identical results by definition; the optimizer relies on this to substitute a faster expression safely.
Scoring: 11–13 you see the algebra under the SQL — Part II will feel natural. 8–10 review the mapping table. Below 8, re-read "SQL is algebra in disguise" before Chapter 5.