
----
Use cases:[2]
autoparts inventory (book keeping page statics of sales/sales person, parts, inventory on hand, etc)
internet statistics for through put on all interfaces on group of servers [0]
--- topic related books:
Joe Celko has book series 'SQL for Smarties' that covers basic through advanced aggrecation with sql using example queries.
Joe Celko's 'Trees and Hierarchies in SQL for Smarties' covers some of the ideas related to 'SQL statment returned a database'?
---
[0]: https://dba.stackexchange.com/questions/173044/nested-aggreg...
[1] : http://unicon.org/
[2] : https://cs.uwaterloo.ca/~tozsu/courses/CS338/lectures/6%20Ne...
http://www.amazon.com/Hierarchies-Smarties-Edition-Kaufmann-...
He spends a chapter on each of the models outlined in this post: adjacency, path, and nested set models.
1. Joe Celko's Trees and Hierarchies in SQL for Smarties 2. Joe Celko's Thinking in Sets: Auxiliary, Temporal, and Virtual Tables in SQL
I know this was a minor point, but I think it speaks to the overall topic, so I'll poke at it.
Adjacency lists are perhaps the worst way to store a graph / tree in RDBMS. They may be the easiest to understand, but they have some of the worst performance characteristics, especially if your RDBMS doesn't have Recursive CTEs. This starts to matter at a much lower scale than you might think; several million rows is enough to start showing slowdowns.
This book [0] (Joe Celko's Trees and Hierarchies in SQL For Smarties) shows many other options, though it does lack the closure table approach [1], which is my preferred approach.
And here, we come full circle back to the long-held friction between DBs and applications. You start mentioning triggers, and devs flinch, stating that they don't want logic in the DB. In every case I've ever seen, the replacements they come up with is incredibly convoluted and prone to errors, but hey, it's not in the DB. There is no reason to fear triggers, if and only if you treat them the same way that you'd treat code (because it is): added/modified/removed only via PRs, with careful review and testing.
[0]: https://ia804505.us.archive.org/19/items/0411-pdf-celko-tree...
[1]: https://dirtsimple.org/2010/11/simplest-way-to-do-tree-based...
