Wednesday, July 9, 2003, 5:13:02 PM, you wrote: MR> Jon Hall wrote: >>I looked at this method and all the others, and decided to go >>with the non-traditional method outlined here. >>http://www.planet-source-code.com/vb/scripts/ShowCode.asp? >>txtCodeId=7321&lngWId=4
MR> Thats actually a fairly old idea. Always seemed to me that inserting records or reordering would be a great big PITA. MR> Nice bit of attitude copped by the author at the end of his little dissertation. I speak not for this guy...except to say he sounds pretty typical of the average VB dork's I run into. If I could find this method documented elsewhere...believe me I would have posted it instead. :) Inserting is fairly easy as long as you have the parent, and the number of records in the subtree you are looking to insert into. One line of code actually + the insert. <cfset newserial = parentSerial + numberFormat(val(right(cat.serial[cat.recordCount], 3)) + 1, "000")> I haven't implemented a reindexer using this method...but it would need to be an offline one if the tree was too big. I haven't run into the need yet for one though. To me, the unbeatable speed of this method in reading a sorted tree is worth a bit of kludginess in the implementation though. This is my post from the cfczone list about it... Tuesday, June 17, 2003, 8:30:04 PM, you wrote: AC> I'm still interested to know how the "build a key out of a hash of the AC> node and its depth in the tree" (or whatever it is... I delete these AC> posts as I read them, so forget the details) copes with moving a node to AC> elsewhere in the tree? Pretty easily... Say I have a model like this (which I do use), similar to Matt's abc type tree except it allows 999 nodes instead of 26 at the expense of larger keys. Name Serial Cars 001 Ford 001001 Jaguar 001001001 Volvo 001001002 Lincoln 001001003 GM 001002 Buick 001002001 Cadillac 001002003 Escalade 001002003001 DeVille 001002003002 Say GM sells Cadillac to Ford, I need to move the 001002003* tree below 001001. So it's one simple UPDATE statement using the LIKE keyword to update everything that begins with 001002003 to 001001 + (next unused tree node). This model does end up updating a lot of rows with very large trees, so I have my doubts as to how far it would scale, but it's extremely simple and fast enough for every tree I've done. The actual SQL would end up looking something like this... UPDATE Categories SET Serial = '001001004' + SubString(Serial, (Len('001001004') + 1), Len(Serial) ) WHERE Category_ID LIKE '001002003%' -- jon mailto:[EMAIL PROTECTED] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. http://www.cfhosting.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4