>- see footer for list info -<
Russ,

> The data is not going to change during the few seconds it 
> takes to render the page, thus there is no need to perform 
> hundreds of queries. 1 query will do. 

Sorry, maybe I hadn't made myself clear.  I think that for small data
trees (as appears to be the case in Lee's situation) then the adjacency
list model (i.e. parent/child relationship pairs) is a perfectly
acceptible method.

For any tree stored using the adjancency list model you'll need to do n
queries to retrieve the entire table, where n is the number of nodes in
the tree.  Yes, you can reduce the database load by grabbing all data
into a cached query and then running a QoQ on it, but that's still n
queries.  The nested set model allows retrieval of the complete tree (or
indeed any branch, or a route to a branch etc) with a single query.

My point was not that the data could change in the few seconds it takes
to render the page, but over time.  Each time a new node is added, the
whole tree must be refreshed, resulting in another n queries.  If the
data changes often then is simplicity of the model outweighed by the
extra processing time to generate the tree?

Of course, there's always a downside to any method, and the nested set
model is no exception.  Because of the way data is stored, adding a node
isn't just a case of adding the node and then the relationship; you have
to insert the node in the correct place in the tree, possibly updating
every other node's position at the same time!  This can lead to very
expensive inserts/deletes (and moving nodes is even more of a
nightmare!) but can easily be worth the extra processing. 

But the crux of it is: do whatever fits the situation and that you're
comfortable with!  No point in adding complexity when it's not going to
bring any added benefit in terms of speed or future code maintenance.

Tim.

PS. I seem to be writing a lot.  Maybe I should stop and do some work?
:o\

--
-------------------------------------------------------
Badpen Tech - CF and web-tech: http://tech.badpen.com/
-------------------------------------------------------
    RAWNET LTD - independent digital media agency
    "We are big, we are funny and we are clever!"
     New site launched at http://www.rawnet.com/
-------------------------------------------------------
This message may contain information which is legally
privileged and/or confidential.  If you are not the
intended recipient, you are hereby notified that any
unauthorised disclosure, copying, distribution or use
of this information is strictly prohibited. Such
notification notwithstanding, any comments, opinions,
information or conclusions expressed in this message
are those of the originator, not of rawnet limited,
unless otherwise explicitly and independently indicated
by an authorised representative of rawnet limited.
------------------------------------------------------- 

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to