Cambridge AS Level Computer Science 9618 · 8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)

Q23 · 9618/13/M/J/24 Q4

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

Q239618/13/M/J/24original Q4Structured · 14 marks
Question 4 from 9618/13/M/J/24

Worked solution

(a)

Each show has many performances, but each performance belongs to one show.

Write: many-to-one (many PERFORMANCE records to one SHOW record) [1]

(b)

Create the table with brackets, give each of the four fields a data type, then set the primary key and the foreign key.

CREATE TABLE PERFORMANCE(
    PerformanceID VARCHAR(4) NOT NULL,
    ShowID VARCHAR(4) NOT NULL,
    ShowDate DATE,
    StartTime TIME,
    PRIMARY KEY (PerformanceID),
    FOREIGN KEY (ShowID) REFERENCES SHOW(ShowID)
);

CREATE TABLE PERFORMANCE with opening and closing brackets [1]

All four fields set with suitable data types (text for the IDs, date, time) [1]

PRIMARY KEY set as PerformanceID [1]

FOREIGN KEY set as ShowID, referencing the SHOW table [1]

(c)

Join PERFORMANCE to SHOW so the title can be shown, count the performances, and group by show.

SELECT SHOW.Title, COUNT(PERFORMANCE.PerformanceID) AS NumberOfShowings
FROM PERFORMANCE INNER JOIN SHOW
ON PERFORMANCE.ShowID = SHOW.ShowID
GROUP BY SHOW.Title;

COUNT of a field from PERFORMANCE with a suitable name using AS [1]

A correct FROM clause [1]

Tables joined on ShowID (INNER JOIN ... ON, or WHERE) [1]

GROUP BY the title, with the title selected [1]

A WHERE join with a comma-separated FROM list also scores.

(d)

Write any five of these points (the last three below are extra accepted points):

A CUSTOMER table with a suitable primary key such as CustomerID [1]

... with other suitable fields, including FirstName, LastName and Email [1]

A BOOKING table with a suitable primary key such as BookingID [1]

... that stores CustomerID as a foreign key to link to CUSTOMER [1]

... and stores PerformanceID as a foreign key to link to PERFORMANCE [1]

A linking table (for example BOOKING_SEAT) with a suitable primary key, because one booking can include many seats

... that stores BookingID as a foreign key to link to BOOKING

... and stores SeatID (to link to SEAT)

KEY IDEAUse one table per kind of thing, and link them with foreign keys, using a linking table when a booking can hold many seats.
TOTAL 14 marks

Official mark scheme

Mark scheme for 9618/13/M/J/24 question 4
VIDEO
▶ Starts at Q4 (24:53)

Starts at Q4 (24:53) · 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.