The "really correct" way to represent a tree data is with a NODE and a LINK table. That means there is no nullable PARENT_ID column. Of course the "unique sibling names" constraint would also require a more complicated construct on most SQL databases (trigger, etc.).
Really, there is no perfect and easy solution for this problem. However, on the DBMSs I've tried, a composite unique constraint which spans a NULLable column works fine and also enforces a "unique root names" constraint.
_________________ JAVA PERSISTENCE WITH HIBERNATE http://jpwh.org Get the book, training, and consulting for your Hibernate team.
|