Reputation: 135
In MySQL database I have a table called Course
which have classroom
and timeslot
columns so I want to create a constraint that checks no two course can have the same association of classroom
and timeslot
. any help is appreciated.
Upvotes: 0
Views: 22
Reputation: 613
You can create a unique constraint with multiple columns like this:
ALTER TABLE Course ADD UNIQUE unique_classroom_time (classroom, timeslot);
Upvotes: 1