• Hugo Kornelis (4/25/2013)


    L' Eomot Inversé (4/25/2013)


    But I have a minor quibble: if this is a business rule, it should be enforced by the schema if possible, not by code; and this is a classic example of a rule that can be enforced by a check constraint.

    For a production implementation, I fully agree that a trigger, even a well-coded one, would be a terrible way to implement this rule.

    I was pretty sure you would:-P

    But for a QotD about triggers, using a CHECK constraint would not have been a very smart choice! 😉

    And there's the challenge to ingenuity: devise a rule which can't be implemented as a check constraint (or any other sort of constraint) and therefor has to be implemented as a trigger (because ad hoc updates and inserts and deletes are allowed, so a trigger is the only way you can be sure of executing the code when needed) while at the same time the rule and the trigger are sufficiently non-complex to make a good QotD. I think that might be very difficult, depending on where the commplexity limit is.

    Tom