SQL: hierarchical recursive query

This post is merely a self reminder. Using hierarchical data in a SQL database is very common. It’s complexity clearly points that the management of hierarchical data is not what a relational database is intended for. The tables of a relational database are not hierarchical, but are simply a flat list. But practical usage of parent-child relationship data structure is quite useful.
Continue reading