I wasn't making fun of your code.  I'll freely admit to having writen
code very similar to what you listed, though not recently.  ;)  Rather
I was pointing out deficiencies and explaining them, and my blunt,
straightforward mannerisms were once again warped by email and
misconstrued.  So take no offence to my comments.

The nested set model is a means of storing hierarchial data in a
relational database.  As the names suggest, the two types of data are
different, and consequently there are problems storing one type of
data in a database designed for the other type.  As an example of the
other way around, XML is very good at storing hierarchies, but not
particularly good at storing relationships.

Here's a couple links that discuss the problem.
http://www.dbazine.com/tropashko4.shtml
http://www.intelligententerprise.com/001020/celko.jhtml?_requestid=30247

I've found that data stored in a tree is often "mangement-ish" data
(folders for organizing documents, categories for organizing products,
etc.), rather than the core data (the documents or products).  Thus
it's particularly well suited to caching, as it probably doesn't
change much.

If that's the case, the simplicity of the parentID-itemID mechanism is
very attractive, since the performance issues can be avoided through
caching.  Do your expensive recursive operation (though hopefully with
a few less queries) once, but rather than generate a list of OPTIONs,
generate a recordset that contains the items in the tree order, with
the level as a field (along with whatever other metadata you want). 
Cache that result somewhere, and update it when the categories change.
 Then whenever you need to use the tree, you can just loop over that
recordset and generate what you want.

cheers,
barneyb

On Wed, 17 Nov 2004 01:16:53 -0500, Emmet McGovern
<[EMAIL PROTECTED]> wrote:
> I'd call you brilliant but you made fun of my chunk of code ;)  I cant
> believe I overlooked repeatstring()!  Thanks you thank you thank you.
> 
> Unfortunately I'm not the greatest when it comes to complex sql so I never
> looked at nested set to start with.  Care to enlighten?
> 
> My late night is done!  Hoorah!
> 
> -e
> 

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/blog/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184527
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to