dive into mark

You are here: dive into markArchivesJune 2003In brief, angry grass edition

Monday, June 23, 2003

In brief, angry grass edition

Filed under , , , , , ,

6 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.

    Comment by Paul — Monday, June 23, 2003 @ 2:43 am

  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.

    Comment by Charles Miller — Monday, June 23, 2003 @ 7:06 am

  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

    Comment by Keith Wright — Monday, June 23, 2003 @ 10:49 am

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

    Comment by xian — Monday, June 23, 2003 @ 12:39 pm

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

    Comment by Brian — Monday, June 23, 2003 @ 1:00 pm

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

    Comment by Mark — Monday, June 23, 2003 @ 1:13 pm

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.)



Recent Stuff For You, Special Price Stay Here
  • Greasemonkey Hacks
Good Stuff Buy The Cow Go Away
Dive Into Python
Powered by Google Drink The Milk Don't Steal

 

posts / comments
© 2001-8 Mark Pilgrim