Create a strong candidate key with multiple columns
SQL
Hard
6 views
Problem Description
In table StudentMarks(student_id, exam_date, subject, marks), a student can have only one record per subject per exam_date. Add the right constraint.
Output Format
DDL statement(s)
Sample Test Case
Input:
StudentMarks(student_id, exam_date, subject, marks)
Constraints
Assume table exists
Official Solution
ALTER TABLE StudentMarks ADD CONSTRAINT uq_student_exam_subject UNIQUE (student_id, exam_date, subject);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!