2 Replies Latest reply: May 3, 2011 12:46 AM by Adam Cameron. RSS

    Construct a tree

    hidarikani Community Member

      I would like to know if the following is possible.

       

      I have a MySQL table with three columns: `item_id`, `parent_item_id` and `title`.

      The table is obviously used for storing a tree data structure.

      Up until now I've used PHP to assemble a tree of objects (using table data) and pass it over to Flash.

       

      Can this be done with CF?

        • 1. Re: Construct a tree
          Owain North Community Member

          Absolutely. Take a look at the cftree tag.

          • 2. Re: Construct a tree
            Adam Cameron. Community Member

            Of course it's possible.

             

            However I'd not implement my tree using the "adjacency list model" (where you have nodes which have a reference to their parent nodes), as it's a pretty poor performer for anything other than basic "who's my immediate parent" and "who are my immediate children" operations.

             

            If you need to do ancestor / descendant look-ups, and you're reading more often than you're writing (which is almost always the case with web sites/applications), then you ought to look at the "nested set model" instead.

             

            --

            Adam