An online shop imported its reviews table from an old system without a foreign-key constraint, so one review refers to a product that no longer exists.
products
product_id
name
P1
Kettle
P2
Toaster
P3
Blender
P4
Mixer
P5
Juicer
reviews
review_id
rating
R1
5
R2
4
R3
2
R4
R5
3
R6
R7
P9
1
Each query in the table lists products first and, except for the cross join, uses the condition ON products.product_id = reviews.product_id. Enter the number of rows each query returns as a whole number.
Unlock full course notes by signing up
Row count of a left join with unmatched rows
The tables below come from a small company database, where each employee belongs to at most one department.
departments
employees
Reading employee and supervisor aliases
A company stores employees and their immediate supervisors in the following Staff table. The column staff_id uniquely identifies each employee, and manager_id contains that employee's supervisor's staff_id. NULL indicates no supervisor.
The company runs this query:
Complete the three output rows below in the order returned by the query. Enter each person's name exactly as shown in the source table.
General properties of equality joins
Two tables A and B are joined with the equality condition A.k = B.k on a column k that exists in both tables, and no WHERE clause is applied. Select every statement that is true for all such tables.
Diagnosing inflated totals across two detail tables
An online retailer stores orders, ordered quantities and payments in three tables. The tables below contain all records relevant to this report. Each line_id and each payment_id is unique. Payments apply to whole orders rather than individual order lines, and all monetary amounts are in Canadian dollars (CAD).
Orders
OrderLines