1.Easy
A foreign key is:
- AA column that refers to the primary key of another table
- BA key used by foreign users
- CA key that is always encrypted
- DA column whose values must be unique across all rows of the table
2.Easy
An INNER JOIN returns:
- ARows that do not match
- BAll rows from the left table, with NULLs where there is no match
- COnly rows with matching values in both tables
- DAll rows from both tables
3.Easy
What does UNION do with the results of two SELECT queries?
- AKeeps only rows that appear in the first query but not the second
- BCombines them into one result and removes duplicate rows
- CKeeps only rows that appear in both
- DJoins them side by side on a key
4.Medium
What does GRANT SELECT ON employees TO alice do?
- AAllows the user alice to read the employees table
- BCopies the employees table to alice
- CMakes alice the owner of the database
- DAllows alice to update and delete rows in the employees table
5.Medium
What is a database trigger?
- AA query that a user runs by hand
- BA scheduled backup of the database
- CA type of index that speeds up searches
- DCode that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
6.Medium
Students can take many courses and courses have many students. How is this modelled in tables?
- AWith a foreign key column course_id in the students table pointing to courses
- BBy merging students and courses into one table
- CWith a list of course ids stored in one column
- DWith a junction table holding foreign keys to both students and courses
7.Hard
What does the following return: SELECT name FROM students WHERE grade > (SELECT AVG(grade) FROM students)?
- AStudents with a grade above the average grade
- BStudents with the highest grade only
- CAn error because subqueries are not allowed in WHERE
- DThe average grade of all students
8.Hard
Boyce–Codd normal form (BCNF) requires that for every non-trivial functional dependency X → Y:
- AY is atomic
- BX contains NULL
- CX is a superkey
- DY is a primary key
Answer key
- 1. A · A column that refers to the primary key of another table
- 2. C · Only rows with matching values in both tables
- 3. B · Combines them into one result and removes duplicate rows
- 4. A · Allows the user alice to read the employees table
- 5. D · Code that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
- 6. D · With a junction table holding foreign keys to both students and courses
- 7. A · Students with a grade above the average grade
- 8. C · X is a superkey
Full step-by-step solutions: practise this topic on examproblems.com.