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 | |
|---|---|---|
| 1Students.ClassID (FK) → Classes.ClassID (PK) | AStudent names are stored as repeating columns in the one side's table. Instead, create a Students table with a ClassID foreign key, with one row per student. | |
| 2Classes (1) ───< Students (many) | BEach student row stores the ClassID of one class, so many students can point to the same class record. | |
| 3The foreign key goes on the 'many' side of the relationship, so each student stores the class they belong to. | CSELECT Students.Name, Classes.Teacher FROM Students JOIN Classes ON Students.ClassID = Classes.ClassID; | |
| 4Storing the class details once in a Classes table avoids repeating them in every student record. | DOne class record is linked to many student records, a one-to-many relationship. | |
| 5Classes table: ClassID (PK), Teacher, Student1, Student2, Student3 | EThe foreign key is on the 'one' side. It should be on the 'many' side, so Students has ClassID (FK) and Classes has no StudentID. | |
| 6Classes table: ClassID (PK), StudentID (FK) | FCREATE TABLE Students (StudentID INT PRIMARY KEY, ClassID INT, FOREIGN KEY (ClassID) REFERENCES Classes(ClassID)); |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
one-to-many relationship — One record in a primary table matches many records in a related table. The foreign key sits on the many side, e.g. one class has many students, so class details are not repeated.SELECT * FROM students WHERE classId = 3;FOREIGN KEY (classId)
REFERENCES classes(classId)SELECT className, firstName
FROM classes JOIN students
ON classes.classId = students.classId;INSERT INTO students (firstName, classId)
VALUES ('Ava', 3);CREATE TABLE classes (
classId INT PRIMARY KEY,
className VARCHAR(20));