How do I create a check constraint?
Posted
by Zack Peterson
on Stack Overflow
See other posts from Stack Overflow
or by Zack Peterson
Published on 2010-04-06T20:31:23Z
Indexed on
2010/04/06
21:03 UTC
Read the original article
Hit count: 392
sql-server
|check-constraints
Please imagine this small database...
Diagram
Tables
Volunteer Event Shift EventVolunteer
========= ===== ===== ==============
Id Id Id EventId
Name Name EventId VolunteerId
Email Location VolunteerId
Phone Day Description
Comment Description Start
End
Associations
Volunteers may sign up for multiple events.
Events may be staffed by multiple volunteers.
An event may have multiple shifts.
A shift belongs to only a single event.
A shift may be staffed by only a single volunteer.
A volunteer may staff multiple shifts.
Check Constraints
Can I create a check constraint to enforce that no shift is staffed by a volunteer that's not signed up for that shift's event?
Can I create a check constraint to enforce that two overlapping shifts are never staffed by the same volunteer?
© Stack Overflow or respective owner