Howto

Since you're interested in this triggers and gone so far i made conclusions, that you are expirienced user and the database is installed and running.
Instructions:
1. Download archive with triggers and unzip it
2. Run psql or any other client, to execute next files into target database in next order:
    - language.sql
    - tables.sql
    - functions.sql
    - edit_trigger.sql
    - error_trigger.sql
    And some test data, if you wish:
    - work.sql

Now you have a new scheme "catalog", and a table "tree" in it. All you really need from this staff is just simple function path(int,int) which returns elements between first and second node by id. All other manipulations look absolutely like in adjacency lists model.
--Assign another parent to node
UPDATE catalog.tree SET sid=0 WHERE id=8;
--Insert new one
INSERT INTO catalog.tree (name,sid) values('somenewstaff',0);
--Operations DELETE removes all subnodes also:
DELETE FROM catalog.tree WHERE id=3;
All other boring job this triggers does!
Comments