Scripts for representing and manipulating iererchical data from PostgreSQL database