in reply to Re: Re: (OT?) Recursive sql queries?
in thread (OT?) Recursive sql queries?
Hrm, that looks interesting, the sql is certainly nice and simple enough, but I have to wonder, how do you maintain it? What happens if, after you've got all your nice lft and rgt columns set up, you want to insert a new node someplace?
It's not hard. There previously mentioned Intelligent Enterprise article covers one possible method. It's worth a read. You can do lots of useful things (aggregate reports, deleting subtrees, etc.) very quickly over in SQL land without having to bring stuff out of the database and munge it into a hierarchy on the Perl side.
After thinking about it for a bit, I think the biggest win is just to store 2 ids, an "ultimate parent" and a "sub parent", then I can just get all my nodes in one query and munge them in to a tree in perl.
This, of course, depends on your definition of "biggest win" ;-)
This way you have to have an id for every level of subtree that you want to refer to which means a change to the DB schema if you change the hierarchy.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re^3: (OT?) Recursive sql queries?
by BUU (Prior) on Feb 27, 2004 at 19:52 UTC | |
by geekbunker (Acolyte) on Mar 02, 2004 at 09:47 UTC |