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

Q27 · 9618/12/O/N/25 Q4

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

Q279618/12/O/N/25original Q4Structured · 10 marks
Question 4 from 9618/12/O/N/25

Worked solution

(a)

Say how many rows on each side can be linked, then name the keys.

Write: the relationship between SHIP and CONTAINER is one-to-many (1:M). One ship can carry many containers. [1]

Write: the primary key ShipID in the SHIP table is linked to the foreign key ShipID in the CONTAINER table. [1]

(b)

Use ALTER TABLE to change the table, ADD to add the field, and choose a sensible name and the DATE type.

ALTER TABLE CONTAINER
ADD InspectionDate DATE;

ALTER TABLE statement used on CONTAINER [1]

Extra field added with a suitable name and a suitable type (DATE) [1]

(c)

The ship name is in SHIP but the containers are in CONTAINER, so join the two tables on ShipID, then count.

SELECT COUNT(ContainerID)
FROM CONTAINER, SHIP
WHERE CONTAINER.ShipID = SHIP.ShipID
AND ShipName = "Caledonia";

SELECT COUNT used [1]

Correct tables, CONTAINER and SHIP, after FROM [1]

Tables joined on ShipID [1]

Condition for the ship name Caledonia [1]

An INNER JOIN ... ON CONTAINER.ShipID = SHIP.ShipID with WHERE ShipName = "Caledonia" also scores.

(d)

Write any two of these points, 1 mark each:

It lets the user create, modify or delete tables (maintain the database), or set up and change relationships. [1]

It lets the user create forms for data input (with tools such as drop-down boxes, buttons or menus), or design reports to show output neatly. [1]

Other points that score: add a menu to choose different actions, or inspect the database contents and metadata by creating and running SQL queries.

KEY IDEAA foreign key in the many side links to the primary key on the one side, and SQL joins tables on that matching key.
TOTAL 10 marks

Official mark scheme

Mark scheme for 9618/12/O/N/25 question 4
VIDEO
▶ Topic lesson

A lesson on this topic · by Craig'n'Dave. 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.