Worked solution from the Databases Paper 1 Theory Fundamentals booklet, Part 1 of 2.
Draw three lines, each with a crow's foot at the "many" end. Do not draw any extra lines.
CUSTOMER to CUSTOMER_CARD_DATA: one-to-many, crow's foot at CUSTOMER_CARD_DATA [1]
CUSTOMER to ORDER: one-to-many, crow's foot at ORDER [1]
ORDER to ORDER_ITEM: one-to-many, crow's foot at ORDER_ITEM [1]
A candidate key is a field that could be the primary key because every value is different.
Write: CardNumber [1]
Fill the table with any two of these (table and a foreign key in it):
| Table | Foreign key |
|---|---|
| ORDER_ITEM | OrderID |
| ORDER | CustomerID |
| CUSTOMER_CARD_DATA | CustomerID |
One correct table with its foreign key [1]
A second correct table with its foreign key [1]
Write three linked points:
Each order can have many items, so the ORDER table would only be able to hold one item per order [1]
The database would not be normalised / would not be in 1NF [1]
... because of repeated groups of attributes (Type, Height, Width and so on) in the ORDER table [1]
Join CUSTOMER to ORDER, keep only unpaid orders, add up the cost for each customer.
SELECT CUSTOMER.CustomerID, CUSTOMER.Name, SUM(ORDER.TotalCost) AS TotalOwed FROM CUSTOMER INNER JOIN ORDER ON CUSTOMER.CustomerID = ORDER.CustomerID WHERE ORDER.Paid = FALSE GROUP BY CUSTOMER.CustomerID;
Selecting the customer ID, name and SUM of TotalCost with a suitable title using AS [1]
FROM with a suitable join of the two tables (ON or WHERE) [1]
The condition Paid = FALSE [1]
GROUP BY customer [1]
▶ Starts at Q5 (1:02:20)
Starts at Q5 (1:02:20) · by Pseudocode Pro. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.