Chaps 28 & 29. (ok, I had to read both but it sounds like you already
understand the concepts.) The end of chap 29 he gives a simple example for
maintaining what you are talking about.  I used it to write a dynamic menu
system for a web portal for a client. It is possible to do and not terribly
difficult. Given the lack of stored procedures you do end up executing 8-10
sql commands one after the other but if you are using a transaction safe
table type (*COUGH*InnoDB*COUGH*) then it works pretty good.

Unlike one of the suggestions I read here, this system doesn't like holes in
the numbers. But he gives code for adding and subtracting nodes.  By
combining the two, I actually made it so the client could move entire


* Cal Evans
* The Virtual CIO

-----Original Message-----
From: José Moreira [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 19, 2002 10:45 AM
To: Php-Db (Correio electrónico)
Subject: [PHP-DB] trees in MySQL

hello im implementing a portal and im choosing between the 'Nested Set' and
'Adjacency Lists tree' models.

im perfectly aware of the 'Adjacency Lists tree' model how-to and I am
studying the 'Nested Set', example follows :

CREATE TABLE LanguageTree (

, Parent VARCHAR(255)
, Lft LONG
, Rgt LONG
, INDEX idxLft (Lft)
, INDEX idxRgt (Rgt)
) Comment = "Related languages";

            A[1 12]
          /          \
         /                \
    B[2 3]       C[4 11]
           /          \
          /            \
          D[5 8]     F[9 10]
          E[6 7]

my doubt is that if i want to insert a new node, for example 'G' under 'A'

            A[1 12]
          /     |     \
         /               \
    B[2 3]    G[]   C[4 11]
           /             \
          /               \
          D[5 8]         F[9 10]
          E[6 7]

i have? to update almost every left,righ fields after that node, resulting
in a website performance downgrade ....

help? even if thjats the only way, how can i do it? perhaps im getting it
wrong ...

best regards

José Moreira

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to