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 | |
|---|---|---|
| 1orders(order_id, customer_id, total) | AThe name field is not in the orders table, which holds only customer_id. The query needs a JOIN to customers. | |
| 2customers(customer_id, name, city) | BON orders.customer_id = customers.customer_id | |
| 3To show each order with the customer's name, join the two tables so matching rows appear together | CSELECT customers.name, orders.total FROM orders JOIN customers ON orders.customer_id = customers.customer_id; | |
| 4The foreign key is the bridge: a join matches it to the primary key in the other table | DThe ON condition matches the wrong field. It should match the foreign key orders.customer_id to customers.customer_id. | |
| 5SELECT name, total FROM orders; | EThe customer name lives in this table, where customer_id is the primary key | |
| 6FROM orders JOIN customers ON orders.order_id = customers.customer_id | FThe orders table holds only a customer_id, not the customer's name |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
JOIN — A join matches each foreign key value in one table to the primary key value in another, so rows from both tables show together. Rows with no match are left out.SELECT orders.orderId, students.firstName
FROM orders JOIN students
ON orders.studentId = students.studentIdSELECT orders.orderId, students.firstName
FROM orders JOIN students
ON orders.studentId = students.studentIdSELECT orders.orderId, students.firstName
FROM orders JOIN students
ON orders.studentId = students.studentIdSELECT orders.orderId, students.firstName
FROM orders JOIN students
ON orders.studentId = students.studentIdSELECT orders.orderId, students.firstName
FROM orders JOIN students
ON orders.studentId = students.studentId