Re: tree structure class
| From: | Tomas V.V.Cox | Date: | Sat, 13 Oct 2001 17:02:30 +0000 |
| Subject: | Re: tree structure class | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-2272@lists.php.net to get a copy of this message | ||
Wolfram Kriesing wrote:
>
> > The url that made me understand that:
> >
> >
> > http://research.calacademy.org/taf/proceedings/ballew/index.htm
> thanks for the link, now i got it too :-)
>
> as i understand using the nested-set-model is very good for saving
> huge trees in the db, when you know the tree structure
> and when you want to work with chunks of the tree
> - how about dynamically inserting, moving and deleteing nodes?
> does everything need to be updated?
> sorry i am not too deep into this - yet
Where this method is most powerful is retrieving data. You can easily
retrieve branchs, leaves, nodes in context ... all with only one simple
query. The insert/delete/update operations are more expensive, but not
too much. Any way the times you need to do such operations comparing
with the times you need to retrieve data is insignificant.
I'm really interesting in develop the DB_Visitation class, I'll start
when find some time :-)
> my aims actually were
> - reading a tree from the db (xml file would be cool too) and
> "having" it in an array, to manipulate, walk, and use the tree
I like the amount of info you provide for each node, really powerful. To
make the class lesser specific, an idea could be to have classes or
methods to load/save data (from DB, xml, array, email/news msgs) and
others to build the tree struct/navigate.
> - especially accessing every element from anywhere, finding my root,
> get my path and whatever ...
> - AND saving as little information as necessary in the db also for
> not needing to update so much when i change/insert something
> thats why i have to "build" the tree array after reading the data
> from the db
> - this i realized using an array which refers to its surrounding
> elements via [parent] [child] [next] [previous]
> [children] is the list of all direct children
Other idea could be to add extra info [left] and [right], so people
could still benefit of visitations in the tree array.
> - it was definitely not thought to be a dynamic html-menu, if one
> wants to do that extending this class - fine, but that was not my
> intention
There were a discussion time ago about the Menu class and its strange
data struct. Perhaps we could extend the Menu class to use this new tree
format.
> - i just wanted to have a way to handle trees easily
Like most of us :-)
> you can have a look at my stuff there
> "docuumentation" is best to read in the class-source header
> http://wolfram.kriesing.de/programming/index.php
>
Good stuff.
Tomas V.V.Cox