mostlylucid

scott galloway's personal blog...
posts - 916, comments - 758, trackbacks - 11

My Links

News

Archives

Post Categories

Misc. Coding

I Suck!

Yeah, yeah, I'm sorry I've been negelecting you my lovely reader. There's just a whole lot to play with at the moment, just got a reasonably priced Video Camera, my lovely bike, been playing with VS.NET 2005 Beta 1, getting a new deployment (and tracking down a deadlock) on this site and finally playing with Adobe Premiere Pro - which is just awesome, if you've been stuck with Windows Movie Maker, try a real editing package!
Whew...as well as that I've been looking into SQL Hierarchies using something called 'Nested Sets' by Joe Celko - this really is the best way I've seen of doing hierarchies (well, trees) in SQL. Also ordered his book on the subject Joe Celko's Trees and Hierarchies in SQL for Smarties ...so, with all of that I have to get back to this site. I was very aware that I was just metablogging for a while there which I personally can't stand. So,l no promises but I'll try and get back to things as soon as I can!

UPDATE: Ooh, this is a pretty complex subject and really pretty interesting. There's a couple of other links I can recommend this site has the most complete set of links to the best methods of modelling hiearchical data in T-SQL, this site has a really nice method for supporting Nested Sets in a basically 'automatic' way. There's a whole lot to learn about this topic (much of which is mentioned in the book I mentioned earlier) and articles like this on the 'Nested Interval' model look really useful but will take a bit of work to figure out. Luckily the system I'm developing is fairly loosely coupled in it's Schema, allowing me to easily upgrade the hierarchical model I use if necessary...

Print | posted on Tuesday, July 06, 2004 8:41 PM | Filed Under [ Books SQL ]

Feedback

Gravatar

# re: I Suck!

Yeah, those nested sets are cool. I've read about them several times, but the complications in inserts and updates were enough to keep me from using them yet. I've been doing my hierarchial SQL stuff with XML lately - I'm hoping that Yukon's XML support makes hierarchies easier.

7/8/2004 5:28 AM | Jon Galloway

Gravatar

# re: I Suck!

I also had a concern about the updates - which require an update to the left and right edge values of each item on every update in the version in the article. I got the book yeaterdfay and it has some really interesting stuff in it about how to handle this - first is using 'spreads' where you allow spaces between parent nodes allowing you to insert a number of items before updating the edges - which you can even do in a scheduled job. I'm obviously still reading but I'll probably end up going for a hybrid model for my current projects, using multiple nested sets each linked together by either another parent nested set (so each of the 'child sets' becomes essentially a single node in the parent set) or using 'adjacent lists' - so where I just define a 'parent node' for each nested set. I really do recommend the book though, it really opens up new ways of thinking about trees and hiearchies in SQL!

7/8/2004 11:58 AM | Scott Galloway

Gravatar

# re: I Suck!

I am very dissapointed that Celko's book omitted the most common way hierarchies are represented in Data Warehouses using a "hierarchy bridge table". See Kimball's book "Data Warehouse Toolkit" for details. This solution trades away storage space for greater speed. It works for convergent graphs and other arbitrary directed acyclic graphs, like bill of materials that reuse assemblies, where the nested sets model fails (p.164).

7/12/2004 3:47 PM | Steve Wright

Gravatar

# re: I Suck!

Very interesting...don't suppose you know any online references for this? In my current instance, I only really need a simple tree model...Celko's method is just fine for this...

7/12/2004 6:01 PM | Test Comment

Comments have been closed on this topic.

Powered by: