I've seen a fair share of databases, and every now and then you want to store a hierarchy of data. If you want to be able to store a hierarchy of an unknown depth i.e. a family tree, this can be simple to store, but complex to then query. Now I thought the only solution (in a Relational DB), is something called the Adjacency List Model where you have a self-referencing table, for example a Person table, where a person may have a foreign key to Father and Mother, both of whom are also in the Person table. The awkward thing with this, is that to properly query to an unknown depth you need to be able to write Recursive Queries, and not all databases support this. Additionally the queries are a bit complex and do not perform well.
While trying to find out if Access supports recursive queries (which it doesn't without using VBA to do the recursion), I found out about the Nested Set Model. This an alternative to the Adjacency List Model, and something I found very interesting.
Read Mike Hillyer's article for full details on both the Adjacency List, and Nested Set models.
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
Saturday, 14 August 2010
Subscribe to:
Posts (Atom)