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%'

-- 
mailto:[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to