9618/11/M/J/23 question 2: worked solution (May/June 2023, paper 11)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 8.3 Data Definition Language (DDL) and Data Manipulation Language (DML) Worked solution from the Databases Paper 1 Theory Fundamentals booklet, Part 2 of 2. Q20 9618/11/M/J/23 original Q2 Structured · 16 marks 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 key Database table BirdID BIRD_SEEN PersonID BIRD_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 IDEA Foreign 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 VIDEO ▶ Starts at Q2 (19:58) Starts at Q2 (19:58) · by Pseudocode Pro. Tap the picture to open it on YouTube.