Is it possible you are taking an intro course in SQL?
Anyway, the answer is that you would need a procedural language function to enforce this constraint.
There are probably many better places to ask this question, even the Q&A Forum here at OpenACS would be better, but maybe an open source db forum somewhere. Suggestions, anyone?
The main problem with the question is that hierarchies in SQL don't exist, they are invented by the end user. You decide, by repeated application of a query, what hierarchy exists between objects.
If this question goes along with the previous one you asked about, with the ordering of parent, child, grandchild, then the easy intro SQL course answer is to enforce the child id to be greater than the parent id.