Cambridge AS Level Computer Science 9618 · 8.1 Database Concepts

Q13 · 9618/11/M/J/25 Q5

Worked solution from the Databases Paper 1 Theory Fundamentals booklet, Part 1 of 2.

Q139618/11/M/J/25original Q5Structured · 13 marks
Question 5 from 9618/11/M/J/25

Worked solution

(a)

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]

(b)

A candidate key is a field that could be the primary key because every value is different.

Write: CardNumber [1]

(c)

Fill the table with any two of these (table and a foreign key in it):

TableForeign key
ORDER_ITEMOrderID
ORDERCustomerID
CUSTOMER_CARD_DATACustomerID

One correct table with its foreign key [1]

A second correct table with its foreign key [1]

(d)

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]

(e)

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]

KEY IDEADraw crow's feet on the foreign-key side, and use GROUP BY with SUM to total values for each customer.
TOTAL 13 marks

Official mark scheme

Mark scheme for 9618/11/M/J/25 question 5
VIDEO
▶ 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.