NYCPHP Meetup

NYPHP.org

[nycphp-talk] Managing Nested Sets in a Database

csnyder chsnyder at gmail.com
Wed Nov 9 17:48:30 EST 2005


On 11/9/05, Jeff Loiselle <jeff.loiselle at gmail.com> wrote:
> Chris,
>
> As I've started to mess around with fncyNode a bit, it seems to work
> well. I was wondering:
>
> a. I want to add a "name" column and modify the appendTo() function to
> save it. Is there a better way? Should I be extending the class?
>
> b. Should I be treating this code as a sample, or is it stable for development?
>

a) I extend the class. I keep everything other than the id, parentId,
lt and rt in another table, and use a join in order to select records.
This keeps the node table limited to just integers, which should speed
the massive update operations that need to be performed every time you
insert or move a node (since fields are all fixed size). That was
Hans' thinking, anyway (and I'm not a DB Admin).

b) Aside from the addition of numChildren() the interface hasn't
changed since last October. We've been using it all over the place for
a year with no problems. Not high-traffic sites by any means, but
constant daily use with no tree corruption on sets of 3000-5000 nodes.
I've tested it up to 50,000 nodes; inserts can take 3-5 seconds at
that size, but lookups are as fast as ever.


--
Chris Snyder
http://chxo.com/


More information about the talk mailing list