Worked solution from the Databases Paper 1 Theory Fundamentals booklet, Part 1 of 2.
One exam has many questions, and each question belongs to one exam. Write: one-to-many (1:M) [1]
ExamID looks like a number with leading zeros, so store it as text. Level and TotalMarks are whole numbers.
CREATE TABLE EXAM(
ExamID VARCHAR(8) NOT NULL,
Subject VARCHAR(20),
Level INTEGER,
TotalMarks INTEGER,
PRIMARY KEY (ExamID)
);CREATE TABLE EXAM with opening and closing brackets [1]
All fields with suitable data types and commas at the ends of lines [1]
ExamID as the primary key [1]
ALTER TABLE EXAM_QUESTION ADD FOREIGN KEY (ExamID) REFERENCES EXAM(ExamID);
ALTER TABLE EXAM_QUESTION [1]
Link ExamID to ExamID in EXAM [1]
Describe the new tables and how they link (any five points score; the last two below are extra accepted points):
A STUDENT table with a suitable primary key, for example StudentID [1]
A linking table between STUDENT and EXAM with a suitable name and primary key [1]
...it includes the primary key of STUDENT as a foreign key to join with STUDENT [1]
...and the primary key of EXAM as a foreign key to join with EXAM [1]
A second linking table between STUDENT and EXAM_QUESTION with a suitable name and primary key [1]
...it includes the primary key of the table it joins to as a foreign key
...it stores the ExamQuestionID and the mark for that question
▶ Starts at Q4 (38:59)
Starts at Q4 (38:59) · 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.