1.Easy
A customer can place many orders, but each order belongs to exactly one customer. What type of relationship is this?
- AMany-to-many
- BOne-to-many
- CZero-to-zero
- DOne-to-one
2.Easy
Which rows does WHERE price BETWEEN 10 AND 20 select?
- ARows with price equal to 10 or 20 only
- BRows with price from 10 to 20, including 10 and 20
- CRows with price above 10 and below 20, excluding 10 and 20
- DRows with price outside the range 10 to 20
3.Easy
In a LIKE pattern, what does the _ (underscore) wildcard stand for?
- AZero or more characters
- BA space character
- CAny letter but no digits
- DExactly one character
4.Medium
A foreign key is declared with ON DELETE CASCADE. What happens when a parent row is deleted?
- AThe child rows that reference it are deleted automatically
- BThe parent row is copied to an archive table
- CThe delete is always rejected
- DThe foreign key in the child rows is set to NULL automatically
5.Medium
Which statement removes all rows of a table, keeps its structure and cannot take a WHERE clause?
- ATRUNCATE TABLE
- BALTER TABLE
- CDROP TABLE
- DDELETE FROM with a WHERE clause
6.Medium
A LEFT JOIN returns:
- AOnly matching rows from both tables
- BAll rows from the left table and matching rows from the right, with NULLs where there is no match
- CAll rows from the right table only
- DRows that match in neither table
7.Hard
What does a FULL OUTER JOIN return?
- AOnly unmatched rows
- BOnly matching rows
- CThe Cartesian product, pairing each row of one table with every row of the other
- DAll rows from both tables, matched where possible and NULL-filled otherwise
8.Hard
Which SQL feature is best suited to finding every employee below a manager in an organisation tree of unknown depth?
- AA single self-join of the employees table on manager_id
- BA recursive common table expression (WITH RECURSIVE)
- CA GROUP BY on manager_id
- DA UNIQUE constraint on manager_id
Answer key
- 1. B · One-to-many
- 2. B · Rows with price from 10 to 20, including 10 and 20
- 3. D · Exactly one character
- 4. A · The child rows that reference it are deleted automatically
- 5. A · TRUNCATE TABLE
- 6. B · All rows from the left table and matching rows from the right, with NULLs where there is no match
- 7. D · All rows from both tables, matched where possible and NULL-filled otherwise
- 8. B · A recursive common table expression (WITH RECURSIVE)
Full step-by-step solutions: practise this topic on examproblems.com.