O'Reilly logo

Defensive Database Programming with SQL Server by Alex Kuznetsov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Advanced Use of Constraints

In the previous chapter, as well as in Chapter 4, we discussed some of the common problems with enforcing data integrity logic in triggers. Some developers have a tendency to hide all sorts of twisted logic inside the body of a trigger, in order to enforce complex business rules. Once implemented, a trigger tends to sink quietly into the background and get forgotten...until it suddenly begins misfiring and causing seemingly inexplicable data integrity issues. For example, as we proved in Chapter 4, a trigger that works when using the standard READ COMMITTED isolation level may fail under the snapshot isolation levels.

Constraints are, in general, a safer haven. As long as a constraint is trusted, then we know ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required