1.Easy
Which clause filters rows before grouping?
- AHAVING
- BGROUP BY
- CWHERE
- DORDER BY
2.Easy
What is a candidate key?
- AA minimal set of columns that uniquely identifies each row
- BA column that is waiting to become a foreign key
- CAny column that contains NULL values
- DA set of columns shared between two tables to link their rows
3.Easy
What is a primary key?
- AThe first column of every table
- BA password for the database
- CA column that may hold duplicate values but must never contain NULL
- DA column or set of columns that uniquely identifies each row
4.Medium
A table has rows where col is NULL. Which rows does WHERE col = NULL return?
- AAll rows of the table
- BNo rows, because the comparison is unknown
- COnly the rows where col is NULL, as with IS NULL
- DAn error in every database
5.Medium
In relational algebra, the selection operator (σ) corresponds to which SQL clause?
- AWHERE
- BSELECT list
- CORDER BY
- DGROUP BY
6.Medium
What does SELECT name, CASE WHEN grade >= 5.5 THEN 'pass' ELSE 'fail' END FROM results return?
- AEach name with the label 'pass' or 'fail' depending on the grade
- BOnly the students who passed
- CThe number of students who passed and failed
- DAn error because CASE is not allowed in SELECT
7.Hard
After customers LEFT JOIN orders, why use COUNT(o.id) rather than COUNT(*) to count orders per customer?
- ACOUNT(*) counts the NULL-filled row as 1 for customers without orders
- BCOUNT(o.id) counts only distinct customers
- CCOUNT(*) ignores rows with NULL values
- DCOUNT(*) is not allowed after a join
8.Hard
Why is NATURAL JOIN considered risky in production queries?
- AIt is not supported by any database
- BIt ignores primary and foreign keys and keeps only NULL rows
- CIt joins on every column with the same name, so a new column can silently change the result
- DIt always returns a Cartesian product
Answer key
- 1. C · WHERE
- 2. A · A minimal set of columns that uniquely identifies each row
- 3. D · A column or set of columns that uniquely identifies each row
- 4. B · No rows, because the comparison is unknown
- 5. A · WHERE
- 6. A · Each name with the label 'pass' or 'fail' depending on the grade
- 7. A · COUNT(*) counts the NULL-filled row as 1 for customers without orders
- 8. C · It joins on every column with the same name, so a new column can silently change the result
Full step-by-step solutions: practise this topic on examproblems.com.