Amer,

It's still worth storing the parentId, because you can easily recreate the
fullpath if (when!) your code screws up a set of full paths.  You can also
write a reliable sanity checker that checks the full path of all the nodes
in the table based on the parentids.

Also, to locate multiple children of a node, it's a more efficient query to
use "where parentid = x", rather than "where fullpath like '1/2/3/4/%'"

All the best,

Andy


> Yes, excellent idea. It's the classic 'linked list' from my old Pascal
> days. While playing with it I realized that you only have to save the
> ID, Name and the FullPath (parents) data. For example, using Andy's
> data:
>
> ID | Name | FullPath
> --------------------
> 1  | Bob  | 0
> 2  | John | 0/1
> 3  | Elm  | 0/1
> 4  | Sue  | 0/1/2
> 5  | Dave | 0/1/2/4
> 6  | Fred | 0/1/2/4/5
>
> The FullPath doesn't need the the 'leaf' or bottom node - it can be
> derived (it's the ID). Using a 'split' function on the FullPath data you
> can pull out the individual parents.
> --
> /* All outgoing email scanned by Norton Antivirus 2002 */
> Amer Neely, Softouch Information Services
> W: www.softouch.on.ca
> E: [EMAIL PROTECTED]
> V: 519.438.5887
> Perl | PHP | MySQL | CGI programming for all data entry forms.
> "We make web sites work!"
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to