Pages

Monday, February 11, 2008

Hierarchies in SQL

I have recieved couple of mails on how to write hierarchial queries in SQL Server. before i start writing something aorund this i looked at the google and found the following information.

Hierarchies are sometimes difficult to store in SQL tables...things like trees, threaded forums, org charts and the like...and it's usually even harder to retrieve the hierarchy once you do store it. Here's a method that's easy to understand and maintain, and gives you the full hierarchy (or any piece of it) very quickly and easily.

While XML handles hierarchical data quite well, relational SQL doesn't. There are several different ways to model a hierarchical structure. The most common and familiar is known as the adjacency model.

Check out more information on this:
http://www.sqlteam.com/article/more-trees-hierarchies-in-sql

No comments: