Cover of Joe Celko's Trees and Hierarchies in SQL for Smarties,

Joe Celko's Trees and Hierarchies in SQL for Smarties,

by Joe Celko · first published 2004

6mentions
5recommended by
6HN commenters
2013–2025first – last mentioned

83% recommend17% neutral

Why HN recommends it

Covers the main ways to store tree and hierarchy data in SQL, such as adjacency, path, and nested set models, with a chapter on each. Good starting point for developers who need to model trees in relational databases.

Summarised by Claude from recommending comments

Affiliate links. As an Amazon Associate I earn from qualifying purchases.

Mentions per year

10 2007: 0 mentions2008: 0 mentions2009: 0 mentions2010: 0 mentions2011: 0 mentions2012: 0 mentions2013: 1 mention2014: 1 mention2015: 0 mentions2016: 1 mention2017: 1 mention2018: 0 mentions2019: 0 mentions2020: 0 mentions2021: 0 mentions2022: 0 mentions2023: 1 mention2024: 0 mentions2025: 1 mention2026: 0 mentions200720172026

What Hacker News says

  • Todd · Nov 21, 2014 · Recommends

    A good book on the subject is Joe Celko's Trees and Hierarchies in SQL for Smarties. 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.

    on “Representing Trees in PostgreSQL” ↗
  • jamesmiller5 · May 8, 2013 · Recommends

    For those interested in sharpening their SQL skills I have found these two books to be a great resource. 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

    on “Learn SQL, dammit” ↗
  • osxman · Feb 6, 2017 · Recommends

    Joe Celko's Trees and Hierarchies in SQL for Smarties (book) is a good start for better understanding/defining trees. http://a.co/9eVzvji

    on “Why Don't We Have a General-Purpose Tree Editor? (2014)” ↗
  • sitkack · Dec 8, 2016 · Recommends

    There is an excellent book on this subject, "Joe Celko's Trees and Hierarchies in SQL for Smarties".

    on “Models for hierarchical data (2010)” ↗
  • sargstuff · Dec 12, 2023 · Recommends

    …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...

    on “What if an SQL Statement Returned a Database?” ↗
  • sgarland · May 26, 2025 · Mentions

    …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.…

    on “Design Pressure: The Invisible Hand That Shapes Your Code” ↗

Keyboard shortcuts

/
Focus search
j / k
Next / previous book
Enter
Open focused book
Esc
Close / go back
g h
Go to Home
g t
Go to Top all-time
g m
Go to Most recommended
g r
Go to Rising
g f
Go to For You
?
Show this help