These examples are referenced by the article Storing deep hierarchies in a database. They require a MySQL installation, although they should be easily portable to other relational database engines.
Run setup.sql
first, with a command such as:
mysql -uuser -p < ./setup.sql
This will create a database named nested_sets
and a few individual tables within that database. Once setup is complete, execute each query either with a similar command:
mysql -uuser -p nested_sets < ./query_1_get_country.sql
or, preferably, by copying+pasting individual commands into the command-line shell, for nicer output.