1.Easy
What is a candidate key?
- AA column that is waiting to become a foreign key
- BA set of columns shared between two tables to link their rows
- CAny column that contains NULL values
- DA minimal set of columns that uniquely identifies each row
2.Easy
What does ROLLBACK do in a transaction?
- ADeletes the table
- BUndoes the changes made since the transaction began
- CSaves all changes of the transaction permanently to disk
- DRepeats the last statement
3.Easy
Which statement removes rows from a table?
- ATRUNCATE COLUMN
- BDROP
- CREMOVE
- DDELETE
4.Medium
A foreign key is declared with ON DELETE CASCADE. What happens when a parent row is deleted?
- AThe foreign key in the child rows is set to NULL automatically
- BThe parent row is copied to an archive table
- CThe child rows that reference it are deleted automatically
- DThe delete is always rejected
5.Medium
Which statement about HAVING is correct?
- AIt can use aggregate functions to filter groups
- BIt must come before WHERE in the SELECT statement
- CIt cannot be used with GROUP BY
- DIt sorts the results
6.Medium
Students can take many courses and courses have many students. How is this modelled in tables?
- AWith a list of course ids stored in one column
- BWith a foreign key column course_id in the students table pointing to courses
- CWith a junction table holding foreign keys to both students and courses
- DBy merging students and courses into one table
7.Hard
What does SELECT name, dept, AVG(salary) OVER (PARTITION BY dept) FROM emp return?
- AOne row per department with its average salary
- BOnly employees who earn more than their department average
- CEvery employee row together with the average salary of their department
- DAn error because name is not in a GROUP BY
8.Hard
What does the following return: SELECT name FROM students WHERE grade > (SELECT AVG(grade) FROM students)?
- AStudents with the highest grade only
- BThe average grade of all students
- CAn error because subqueries are not allowed in WHERE
- DStudents with a grade above the average grade
Answer key
- 1. D · A minimal set of columns that uniquely identifies each row
- 2. B · Undoes the changes made since the transaction began
- 3. D · DELETE
- 4. C · The child rows that reference it are deleted automatically
- 5. A · It can use aggregate functions to filter groups
- 6. C · With a junction table holding foreign keys to both students and courses
- 7. C · Every employee row together with the average salary of their department
- 8. D · Students with a grade above the average grade
Full step-by-step solutions: practise this topic on examproblems.com.