I think the logic is too complicated for a CHECK constraint, and I haven't managed to get a user-defined function to work it that context so it may not be possible that way.
Sometimes we need to add ulterior constraints to the table we define. The ALTER TABLE statement enables us to do this. There are several types of constraints we can add. If we want to ensure that all ...