CREATE TABLE "a_tbl_tree" ( "id" integer NOT NULL, "_parent" integer, "_note" character varying(128), "_picture" character varying(255), Constraint "a_tbl_tree_pkey" Primary Key ("id") ); CREATE TABLE "a_tbl_log" ( "_time" timestamp with time zone DEFAULT "timestamp"('now'::text), "_picture" character varying(255) ); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (0,0,'root',''); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (1,0,'Master node 1','mn1.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (2,0,'Master node 2','mn2.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (3,0,'Master node 3','mn3.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (10,1,'Sub-node 1-1','sn11.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (11,1,'Sub-node 1-2','sn12.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (12,1,'Sub-node 1-3','sn13.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (13,1,'Sub-node 1-4','sn14.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (20,2,'Sub-node 2-1','sn21.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (21,2,'Sub-node 2-2','sn22.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (22,2,'Sub-node 2-3','sn23.gif'); INSERT INTO "a_tbl_tree" ("id","_parent","_note","_picture") VALUES (33,3,'Sub-node 3-1','sn31.gif'); CREATE RULE rule_tbl_tree_del AS ON DELETE TO a_tbl_tree DO INSERT INTO a_tbl_log ("_picture") VALUES(OLD._picture);