1.Easy
A foreign key is:
- AA key used by foreign users
- BA key that is always encrypted
- CA column that refers to the primary key of another table
- DA column whose values must be unique across all rows of the table
2.Easy
What is a surrogate key?
- AA key that is only used in views
- BA key made from real-world data such as an email address
- CAn artificial identifier with no business meaning, such as an auto-increment id
- DA key that refers to another table
3.Easy
Which keyword sorts the result of a query?
- AORDER BY
- BARRANGE
- CSORT
- DGROUP BY
4.Medium
Which query returns the number of different cities in the customers table?
- ASELECT SUM(DISTINCT city) FROM customers
- BSELECT DISTINCT COUNT(city) FROM customers
- CSELECT COUNT(city) FROM customers GROUP BY city
- DSELECT COUNT(DISTINCT city) FROM customers
5.Medium
Students can take many courses and courses have many students. How is this modelled in tables?
- ABy merging students and courses into one table
- BWith a list of course ids stored in one column
- CWith a foreign key column course_id in the students table pointing to courses
- DWith a junction table holding foreign keys to both students and courses
6.Medium
What does the "A" in ACID stand for?
- AAccuracy
- BAggregation
- CAtomicity
- DAvailability
7.Hard
Why is NATURAL JOIN considered risky in production queries?
- AIt is not supported by any database
- BIt always returns a Cartesian product
- CIt ignores primary and foreign keys and keeps only NULL rows
- DIt joins on every column with the same name, so a new column can silently change the result
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. C · A column that refers to the primary key of another table
- 2. C · An artificial identifier with no business meaning, such as an auto-increment id
- 3. A · ORDER BY
- 4. D · SELECT COUNT(DISTINCT city) FROM customers
- 5. D · With a junction table holding foreign keys to both students and courses
- 6. C · Atomicity
- 7. D · It joins on every column with the same name, so a new column can silently change the result
- 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.