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 * FROM students JOIN orders; | AA join with no ON condition: every student row is paired with every order row, so most result rows are wrong | |
| 2SELECT * FROM students JOIN orders ON students.studentId = orders.studentId; | BSELECT COUNT(*) FROM students JOIN orders; | |
| 33 customers joined to 4 orders with no ON condition gives 3 x 4 = 12 rows | CFROM orders JOIN products ON orders.productId = products.productId | |
| 4Adding the ON condition stops every row being paired with every other row | DA join with an ON condition: only rows where the student IDs match are kept, so each order pairs with its own student | |
| 5SELECT firstName, name FROM students JOIN products; | EThe ON condition joins the wrong fields. It should match students.studentId = orders.studentId (primary key to foreign key). | |
| 6SELECT * FROM students JOIN orders ON students.points = orders.quantity; | FThe ON condition is missing, so every student is paired with every product and most rows are wrong. Add ON to match the linked fields. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Cartesian product — A join with no ON condition pairs every row of one table with every row of the other, so 3 customers and 4 orders give 12 rows, most of them wrong.SELECT firstName, orderId
FROM students JOIN orders
ON students.studentId = orders.studentId;SELECT * FROM students JOIN orders;
-- 3 rows x 4 rows gives 12 rowsSELECT name, quantity
FROM products JOIN orders
ON products.productId = orders.productId;SELECT name, mark
FROM results JOIN subjects
ON results.subjectId = subjects.subjectId;SELECT COUNT(*) FROM students JOIN orders;
-- no ON, so every pairing is counted