Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1CREATE TABLE houses (house TEXT PRIMARY KEY, headOfHouse TEXT); | AStudent and subject details are repeated on every result row, so the same fact is stored many times. Move them into students and subjects tables and keep only the keys in results. | |
| 2students(studentId, firstName, house) -> houses(house) | BCopying the teacher into results instead of linking by subjectId stores the same fact in two places. Keep teacher only in subjects and link with the foreign key subjectId. | |
| 3One fact in one place: the teacher name is stored once in subjects, not repeated on every results row. | CThe house field in students is a foreign key that links each student back to the one house row that holds the details. | |
| 4After splitting, a join uses the foreign key to bring the linked details back together when needed. | DSELECT name, teacher FROM subjects; | |
| 5One big table: results(studentId, firstName, lastName, subjectName, teacher, mark) | ESELECT students.firstName, results.mark FROM students INNER JOIN results ON students.studentId = results.studentId; | |
| 6results(studentId, subjectId, mark, teacher) -- teacher copied into results as well as subjects | FCreates a separate table so each house and its head are stored once, instead of being repeated on every student row. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
normalisation — Splitting a table so repeated details move into their own table, linked back with a foreign key, so each fact is stored only once and redundancy is reduced.CREATE TABLE houses (
houseId INTEGER PRIMARY KEY,
houseName TEXT);CREATE TABLE students (studentId INTEGER,
houseId INT REFERENCES houses(houseId));INSERT INTO houses VALUES (1, 'Red');
INSERT INTO students VALUES (1, 'Ava', 1);UPDATE houses
SET houseName = 'Crimson'
WHERE houseId = 1;SELECT students.firstName, houses.houseName
FROM students JOIN houses
ON students.houseId = houses.houseId;