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 | |
|---|---|---|
| 1PRIMARY KEY (studentId, subjectId) | ACreates a junction table whose key is made of two fields that link students to subjects | |
| 2CREATE TABLE enrolments (studentId INT, subjectId INT, PRIMARY KEY (studentId, subjectId)); | BA composite primary key: the two fields together identify each enrolment record uniquely | |
| 3Each field alone is not unique: a student appears in many enrolments and a subject has many students, but each pair appears only once | CA table can only have one primary key. Two separate keys do not make a composite key. Both fields must go in one bracket: PRIMARY KEY (studentId, subjectId). | |
| 4A junction table links two tables in a many-to-many relationship by using both foreign keys together as its primary key | DstudentId alone is set as the key, so each student could only be enrolled once. The key needs both fields: PRIMARY KEY (studentId, subjectId). | |
| 5PRIMARY KEY (studentId), PRIMARY KEY (subjectId) | EPRIMARY KEY (studentId, subjectId), FOREIGN KEY (studentId) REFERENCES students(studentId) | |
| 6CREATE TABLE enrolments (studentId INT PRIMARY KEY, subjectId INT); | F(1, 1), (1, 2), (2, 1) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
PRIMARY KEY (studentId, subjectId) — A composite primary key: two or more fields together identify each record uniquely. Each field can repeat alone, but the pair cannot. Used in junction tables.PRIMARY KEY (studentId, subjectId)CREATE TABLE enrolment (
studentId INT, subjectId INT,
PRIMARY KEY (studentId, subjectId));CREATE TABLE enrolment (
studentId INT, subjectId INT,
PRIMARY KEY (studentId, subjectId));CREATE TABLE enrolment (
studentId INT, subjectId INT,
PRIMARY KEY (studentId, subjectId));CREATE TABLE enrolment (
studentId INT, subjectId INT,
PRIMARY KEY (studentId, subjectId));