§

Six comments here (latest comments)

  1. Preorder tree traversal is truly the king of hierarchical-data storing methods.

    As for the ‘indent level’ thing that’s mentioned in that article, it’s even easier than that; it can all be done in SQL. Just join your hierarchy table back onto itself:

    SELECT title, COUNT(*) AS level
    FROM tree
    LEFT JOIN tree AS treelevels
    ON (tree.lft between treelevels.lft and treelevels.rgt)
    GROUP BY TITLE

    It’s slightly tricky to understand, but trust me, it’s nifty.

    One thing that’s a bitch, though, which I mention purely in case anyone decides to convert their database holus-bolus and then gets caught out: it’s very tricky indeed to get the children ordered alphabetically. If you add ‘Green’ and then ‘Apple’ below ‘Fruit’, you’d better hope you never want to retrieve:

    Green / Apple / Red / Cherry / Yellow / Banana

    like that, because you’ll be bald in an hour, I swear.

    — Paul #

  2. The “Python Considered Harmful” link is historically interesting.

    I read the post, vehemently disagreed with it, and then read the follow-ups. To my surprise, not a single response suggested using unit tests as a substitute for compile-time checking. I didn’t quite understand this until I looked at the top of the page and saw the year the thread occurred: 1999. These days, you wouldn’t be able to get away with that sort of question without at least ten people invoking Kent Beck.

    Then I realised how recent 1999 actually was.

    — Charles Miller #

  3. Here is a method for trees in Sql posted on Ward’s Wiki that is very, very slick and efficient.

    http://c2.com/cgi/wiki?TreeInSql

    — Keith Wright #

  4. I think we need another one of those meme-image banners, this one saying “No *I* co-authored RSS!”

    — xian #

  5. I co-authored RSS, and so did my wife!

    — Brian #

  6. http://diveintomark.org/images/noIcoauthoredrss.gif

    — Mark #

Respond privately

I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)



§

firehosecodeplanet

© 2001–9 Mark Pilgrim