Tree manipulation functions for PostgreSQL -  version 1.0beta3
=============================================================

== Introduction ==

A functions library to manipulate trees
and hierarchical structures under PL/pgSQL.

The main idea is to separate the real data from the hierarchical information. 
This can be achieved by using custom, user created tables to store the real data 
and by using this library for the hierarchical information.
The library stores the hierarchical information in its internal structure,
the user then, can access this information by using these functions
and it is also able to create views that combine the real data 
with the hierarchical information.

this version is data incompatible to the previous version 1.0beta1
if you want to transfer data from the previous version then
you must use the import/export facility
please send me email for further instructions.


== Features == 

* add/remove Nodes
* remove subtrees
* tree traversal
* tree level traverse 
* xml/html tree conversion
* user access per node
* import/export tree structures
* get path from root to node
* get anchestor of 2 nodes, leaf nodes, internal nodes ...



== Installation == 

First, you must have created a database in PostgreSQL.

Then, use the operation system shell, to install the  PL/pgSQL handler:

  createlang plpgsql <dbname>


Next, load  the tree_install.sql file into the 
database, eg:
 
  psql -f  tree_install.sql <dbname>




== User Access Installation == 

load the tree_ua_install.sql file into the 
database, eg:

  psql -f tree_ua_install.sql <dbname>

  
  
== Upgrade == 
	
	psql -f  tree_upgrade.sql <dbname>


== User Access Upgrade == 
	
	psql -f  tree_ua_upgrade.sql <dbname>



== Uninstall == 

The library consists of 2 schemas: 
tree and tree_util

To uninstall:
drop these schemas like this:
drop schema tree CASCADE;
drop schema tree_util CASCADE;

If you do this you will lose your tree structures 
that you have registered in the library.



== Usage == 

The library consists of 3 schemas:

1. tree      : this schema holds the user functions. 
               Also it holds the tables and triggers which store 
               the nodes responsible for hierarchical structure information.

2. tree_util : this schema holds the functions required for internal usage.

3. rtree     : this schema holds the functions that can be used by users who have restricted access.

Have a look at functions.txt for a list of functions and data structures.
Also have a look at tutorial.sql for a tutorial about the library usage and views construction.



== Todo == 

1) Documentation.
2) extend user access restrictions functionality.
3) Examine the possibility to add a bigint[] column for storing the path to root for every node.
4) Examine the possibility to use the ltree data type from postgres contrib for storing 
   the hierarchical information.  	 



== Contact == 

Author: Kostas Maistrelis <pgtreelib@postgresql.gr>

I will be glad to hear any comments or suggestions here: <pgtreelib@postgresql.gr>

