Home Forums SQLServerCentral.com Editorials Are Triggers a "legacy" Feature? (Database Weekly, Nov 08 2008) RE: Are Triggers a "legacy" Feature? (Database Weekly, Nov 08 2008)

  • william.sisson (2/19/2013)


    For example for hotel room bookings you need to ensure that the same room cannot be booked for overlapping time periods. You need a constraint to do this that cannot be enforced using referential integrity or check constraints.

    1) If you insist on "begin" and "end" as separate columns, what about a function based table constraint, where the function checks for overlapping ranges?

    2) Alternately, you move on to the "DateOfChange" technique where you have only the "Begin" type column, and you record "Customer A begin" and then either "Customer B begin" or "Empty begin" in another record. LAG/LEAD made this much easier in 2012, but it can still be done without much trouble in earlier versions.