Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1SELECT name, price FROM products | ASELECT firstName FROM students WHERE house = 'Red' | |
| 2CREATE INDEX idx_last ON students(lastName) | BSELECT s.firstName, r.mark FROM students s JOIN results r ON s.studentId = r.studentId | |
| 3Filter early with WHERE so the database returns only the rows needed | CSELECT * returns every column when only a few are needed. Name the required fields, such as SELECT quantity FROM orders. | |
| 4One join is more efficient than running a separate query for every row | DThere is no WHERE clause, so every row comes back even when only in-stock items are needed. Add WHERE stock > 0. | |
| 5SELECT * FROM orders WHERE orderId = 4 | EAsks only for the two fields needed instead of every column, so less data is read and sent back | |
| 6SELECT name FROM products | FBuilds an index on a searched field so the database can find matching records quickly |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
SELECT name FROM products WHERE stock > 0 — An efficient query asks only for the fields and rows it needs: name fields instead of SELECT *, WHERE to filter early, and an index or key to find records fast.SELECT name FROM products WHERE stock > 0;-- Only need each year level
SELECT yearLevel FROM students;CREATE INDEX idxLast ON students(lastName);-- Staff often search by points
CREATE INDEX idxPoints ON students(points);SELECT students.firstName, results.mark
FROM students JOIN results
ON students.studentId = results.studentId;