1.Easy
What does a CHECK constraint do?
- AVerifies the user's password
- BChecks whether a table exists before a query is run on it
- CCounts the rows in a table
- DRejects rows whose values do not satisfy a condition
2.Easy
Which rows does WHERE price BETWEEN 10 AND 20 select?
- ARows with price outside the range 10 to 20
- BRows with price above 10 and below 20, excluding 10 and 20
- CRows with price equal to 10 or 20 only
- DRows with price from 10 to 20, including 10 and 20
3.Easy
What does NULL represent in SQL?
- AA false Boolean
- BA missing or unknown value
- CThe number zero in numeric columns
- DAn empty string
4.Medium
A table stores the customer's address on every order row. Changing the address in one row but not in the others is an example of:
- AA deletion anomaly
- BA phantom read
- CAn update anomaly
- DAn insertion anomaly
5.Medium
What is SQL injection?
- AA technique for inserting many rows quickly with a single INSERT statement
- BA database backup technique
- CA way to add indexes
- DAn attack where user input changes the structure of a SQL query
6.Medium
What does SELECT SUM(amount) FROM orders return when the WHERE clause matches no rows?
- AAn empty string
- B0
- CNULL
- DAn error
7.Hard
Boyce–Codd normal form (BCNF) requires that for every non-trivial functional dependency X → Y:
- AY is atomic
- BX contains NULL
- CY is a primary key
- DX is a superkey
8.Hard
What does EXPLAIN (or EXPLAIN ANALYZE in PostgreSQL) show for a query?
- AA rewrite of the query in relational algebra notation only
- BThe list of users who ran the query
- CThe execution plan chosen by the optimiser, such as scans and join methods
- DThe meaning of each SQL keyword in the query
Answer key
- 1. D · Rejects rows whose values do not satisfy a condition
- 2. D · Rows with price from 10 to 20, including 10 and 20
- 3. B · A missing or unknown value
- 4. C · An update anomaly
- 5. D · An attack where user input changes the structure of a SQL query
- 6. C · NULL
- 7. D · X is a superkey
- 8. C · The execution plan chosen by the optimiser, such as scans and join methods
Full step-by-step solutions: practise this topic on examproblems.com.