Skip to main content
May 3, 2011
Question

Construct a tree

  • May 3, 2011
  • 2 replies
  • 282 views

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?

    This topic has been closed for replies.

    2 replies

    Inspiring
    May 3, 2011

    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

    Owainnorth
    Inspiring
    May 3, 2011

    Absolutely. Take a look at the cftree tag.