1.Easy
In PostgreSQL and MySQL, which clause returns only the first 10 rows of a result?
- ATOP ROWS 10
- BMAX 10
- CFIRST 10 ONLY
- DLIMIT 10
2.Easy
What is a candidate key?
- AAny column that contains NULL values
- BA column that is waiting to become a foreign key
- CA set of columns shared between two tables to link their rows
- DA minimal set of columns that uniquely identifies each row
3.Easy
Statements such as CREATE, ALTER and DROP belong to which part of SQL?
- AData Control Language (DCL)
- BData Definition Language (DDL)
- CData Manipulation Language (DML)
- DTransaction Control Language (TCL)
4.Medium
First normal form (1NF) requires that:
- AEach column contains atomic values and there are no repeating groups
- BEvery table has exactly one column
- CThere are no foreign keys
- DEvery non-key column depends on the whole key and on nothing but the key
5.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:
- AAn update anomaly
- BAn insertion anomaly
- CA deletion anomaly
- DA phantom read
6.Medium
Which query returns the number of orders per customer?
- ASELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id
- BSELECT DISTINCT COUNT(*) FROM orders
- CSELECT customer_id, COUNT(*) FROM orders ORDER BY customer_id
- DSELECT customer_id FROM orders WHERE COUNT(*) > 0
7.Hard
Transaction T1 locks row A and waits for row B, while T2 locks row B and waits for row A. What does a typical DBMS do?
- ALets both transactions wait until one of them commits normally
- BDetects the deadlock and aborts one transaction as the victim
- CCommits both transactions at once
- DMerges the two transactions into one
8.Hard
What does the write-ahead logging (WAL) rule require?
- AEvery query must be logged before it is parsed
- BData pages must be written before the log
- CThe log is written only after a crash
- DA change's log record must reach stable storage before the changed data page does
Answer key
- 1. D · LIMIT 10
- 2. D · A minimal set of columns that uniquely identifies each row
- 3. B · Data Definition Language (DDL)
- 4. A · Each column contains atomic values and there are no repeating groups
- 5. A · An update anomaly
- 6. A · SELECT customer_id, COUNT(*) FROM orders GROUP BY customer_id
- 7. B · Detects the deadlock and aborts one transaction as the victim
- 8. D · A change's log record must reach stable storage before the changed data page does
Full step-by-step solutions: practise this topic on examproblems.com.