April 30, 2003Storing Hierarchical Data in a Database, Part 2 Now, let’s have a look at another method for storing trees. Recursion can be slow, so we would rather not use a recursive function. We’d also like to minimize the number of database queries. Preferably, we’d have just one query for each activity. We’ll start by laying out our tree in a horizontal way. Start at the root node (‘Food’), an
![Storing Hierarchical Data in a Database, Part 2 — SitePoint](https://cdn-ak-scissors.b.st-hatena.com/image/square/fb92d4b133a180e4106d31a5c4d77c584de6c008/height=288;version=1;width=512/https%3A%2F%2Fwww.sitepoint.com%2Fwp-content%2Fthemes%2Fsitepoint%2Fassets%2Fimages%2Ficon.programming.png)