Databases · Junior · Question 67 of 75
What is a composite primary key?
CREATE TABLE enrollments (
student_id bigint REFERENCES students (id),
course_id bigint REFERENCES courses (id),
PRIMARY KEY (student_id, course_id)
);- 1A key that is calculated from other tables
- ✓Correct answer: A primary key made of several columns; here the pair must be unique, so a student can enroll in a course only once
- 3Two separate primary keys in one table
Explanation
Composite keys are typical for junction tables. Each column alone may repeat; only the combination must be unique.