EXPERT RESPONSE
I believe the introduction of Assertions in the SQL standard allows for this type of "constraint" to be declared (as opposed to programmed). However, I don't believe any of the larger database vendors have implemented assertions yet. Frankly, I believe there are still some significant technological hurdles to be overcome before assertions can be implemented without resulting in horrific performance issues.
This model of trees is popular, though clunky in today's relational databases. Oracle and DB2 have extensions to SQL that allow for the traversal of trees; I don't believe SQL Server does. Unfortunately, I believe that your only solutions are to implement your constraint programmatically through triggers (sorry) or alter your data design (sorry). With regard to altering your data design, I might recommend Joe Celko's Associative Model of Trees covered in his book, SQL for Smarties: Advanced SQL Programming.
For More Information
|