This is a discussion on nested set: algorithm for testing the integrity within the MySQL Database forums, part of the Database Forums category; I'm looking for a algorithm which checks if a nested set with many nodes and levels is correct. I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
alexander.buze@googlemail.com wrote:
> I'm looking for a algorithm which checks if a nested set with many > nodes and levels is correct. > > I know the pear class and I have read a few tutorials, maybe there is > a mathematical solution for this test? > > thx. > i think you're talking php. check http://www.phpclasses.org -- lark -- hamzee@sbcdeglobalspam.net To reply to me directly, delete "despam". |
|
|||
|
>> algorithm which checks if a nested set with many nodes and levels is correct. <<
1) Buy a copy of TREES & HIERARCHIES IN SQL 2) Create a view called LftRgt which has all the lft and rgt values unioned in it 3) No gaps in the numbering: (SELECT MAX(rgt) FROM Tree) = (SELECT COUNT(*) FROM LftRgt) 4) No duplicated values: NOT EXISTS (SELECT seq FROM LftRgt GROUP BY seq HAVING COUNT(*) > 1) 5) No overlapping (lft, rgt) pairs: an exercise for the reader |