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

Q20 · 9618/11/M/J/23 Q2

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

Q209618/11/M/J/23original Q2Structured · 16 marks
Question 2 from 9618/11/M/J/23

Worked solution

(a)(i)

Definition: write that a data dictionary is data about the data in the database (metadata about its structure). [1]

Example: table names, field names or data types. [1]

(a)(ii)

Definition: data integrity means the data is consistent and correct, because the database uses methods to keep it that way. [1]

Example: enforcing referential integrity, or validation rules, or cascading update and delete. [1]

(b)(i)

A foreign key is a field that is the primary key of another table. Both are in BIRD_SEEN.

Foreign keyDatabase table
BirdIDBIRD_SEEN
PersonIDBIRD_SEEN

BirdID with BIRD_SEEN [1]

PersonID with BIRD_SEEN [1]

(b)(ii)

Draw three lines. Each normal form joins to its own definition:

1NF → There are no repeating groups of attributes. 2NF → There are no partial dependencies. 3NF → All fields are fully dependent on the primary key.

All three lines drawn as shown [1]

(b)(iii)

BirdID has leading zeros (0123), so store it as characters, not integers. Name and Size are text too.

CREATE TABLE BIRD_TYPE(
    BirdID CHAR(4) NOT NULL,
    Name VARCHAR(9),
    Size VARCHAR(6),
    PRIMARY KEY (BirdID)
);

CREATE TABLE with start and end bracket [1]

BirdID as CHAR or VARCHAR [1]

Name and Size as VARCHAR or CHAR [1]

BirdID as the primary key [1]

(b)(iv)

Join BIRD_TYPE to BIRD_SEEN, choose the person, then group by size to count each size.

SELECT BIRD_TYPE.Size, COUNT(BIRD_TYPE.BirdID)
    AS NumberOfBirds
FROM BIRD_TYPE, BIRD_SEEN
WHERE BIRD_SEEN.PersonID = "J_123"
AND BIRD_TYPE.BirdID = BIRD_SEEN.BirdID
GROUP BY BIRD_TYPE.Size;

COUNT [1]

BIRD_SEEN in the FROM line [1]

BIRD_SEEN.PersonID [1]

BIRD_SEEN.BirdID [1]

GROUP BY [1]

KEY IDEAForeign keys sit in the table that refers to another table, and SQL joins them by matching key to key.
TOTAL 16 marks

Official mark scheme

Mark scheme for 9618/11/M/J/23 question 2
VIDEO
▶ Starts at Q2 (19:58)

Starts at Q2 (19:58) · 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.