/*
    A hierachical data (tree) implementation in SQL using triggers as
    described here:

        http://www.depesz.com/index.php/2008/04/11/my-take-on-trees-in-sql/

    Generated by App::sqltree version 0.0.5_2 with the following
    paramters on Sun Jul 19 06:17:33 2015

        driver:     SQLite
        table:      nodes
        pk:         id
        parent:     parent_id
        type:       INTEGER
        path:       
        path_from:  
        order:      
*/

CREATE TABLE nodes_tree (
    treeid INTEGER PRIMARY KEY,
    parent INTEGER NOT NULL,
    child  INTEGER NOT NULL,
    depth  INTEGER NOT NULL,
    UNIQUE (parent, child)
    FOREIGN KEY(parent) REFERENCES nodes(id) ON DELETE CASCADE,
    FOREIGN KEY(child) REFERENCES nodes(id) ON DELETE CASCADE
);
