Quantcast
Channel: Recursive Query
Viewing all articles
Browse latest Browse all 10

Recursive Query

$
0
0

The code for the Adjacency List Model is actually worse than the Nested Sets Model. IF YOU DO IT RIGHT. Sit down and write constraints to prevent these common


  1. Single root of the tree: since the lft and rgt values are unique the Nested Sets Model, we get it for free

  2. Cycles: Impossible in the Nested Sets Model. Most people do not even bother with the simple “CHECK(emp_id <> boss_id)” in the Adjacency List Model.

  3. Multiple Parents: Impossible in the Nested Sets Mode.

  4. Missing Edges: Impossible in the Nested Sets Mode


What surprised me was that younger programmers understand the Nested Sets Mode immediately. They see (lft, rgt) as XML tags! Older programmers who grew up with pointer chains and sequential files think that the Adjacency List Model is natural. Of course the Adjacency List Model is not normalized and you get all of the anomaly problems.  


--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL


Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>