9618/12/M/J/24 question 4: worked solution (May/June 2024, paper 12)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 8.1 Database Concepts Worked solution from the Databases Paper 1 Theory Fundamentals booklet, Part 1 of 2. Q10 9618/12/M/J/24 original Q4 Structured · 11 marks Worked solution (a) One exam has many questions, and each question belongs to one exam. Write: one-to-many (1:M) [1] (b) 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] (c) ALTER TABLE EXAM_QUESTION ADD FOREIGN KEY (ExamID) REFERENCES EXAM(ExamID); ALTER TABLE EXAM_QUESTION [1] Link ExamID to ExamID in EXAM [1] (d) 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 KEY IDEA Many-to-many links between tables are broken up with a linking table holding the foreign keys. TOTAL 11 marks Official mark scheme VIDEO ▶ Starts at Q4 (38:59) Starts at Q4 (38:59) · by Pseudocode Pro. Tap the picture to open it on YouTube.