For teachers: free to print, copy and use in class. Every new worksheet has new values and its own answer key. A link to ExamProblems on your course page is appreciated.
Name: ____________________ Date: ____________
1.Easy
What does GROUP BY do in a query?
ASorts the rows of the result alphabetically
BRemoves rows with NULL values
CJoins two tables on their common columns
DPuts rows with the same values into groups so aggregates are computed per group
2.Easy
A foreign key is:
AA column whose values must be unique across all rows of the table
BA column that refers to the primary key of another table
CA key that is always encrypted
DA key used by foreign users
3.Easy
What is a candidate key?
AAny column that contains NULL values
BA minimal set of columns that uniquely identifies each row
CA column that is waiting to become a foreign key
DA set of columns shared between two tables to link their rows
4.Medium
An employees table has a column manager_id that refers to another employee. How do you list each employee next to their manager's name?
ACreate a second copy of the table on disk
BUse GROUP BY manager_id only
CJoin the employees table with itself using two aliases
DCombine the table with itself using UNION ALL and a WHERE filter
5.Medium
A column holds the values 10, 20 and NULL. What does AVG(col) return?
ANULL
B30
C10
D15
6.Medium
The orders table has 5 rows, each referring to an existing customer. The customers table has 3 rows. How many rows does an INNER JOIN on customer_id return?
A3
B15
C5
D8
7.Hard
What is a phantom read?
AReading data that was never written
BReading uncommitted changes
CA query that returns no rows
DA repeated query returns new rows inserted by another committed transaction
8.Hard
What does the write-ahead logging (WAL) rule require?
AEvery query must be logged before it is parsed
BA change's log record must reach stable storage before the changed data page does
CData pages must be written before the log
DThe log is written only after a crash
Answer key
1. D · Puts rows with the same values into groups so aggregates are computed per group
2. B · A column that refers to the primary key of another table
3. B · A minimal set of columns that uniquely identifies each row
4. C · Join the employees table with itself using two aliases
5. D · 15
6. C · 5
7. D · A repeated query returns new rows inserted by another committed transaction
8. B · 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.