#!/opt/perlbrew/perls/perl-5.14.2/bin/perl

eval 'exec /opt/perlbrew/perls/perl-5.14.2/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell
use strict;
use warnings;
use OptArgs 'dispatch';

dispatch(qw/run App::sqltree/);

__END__


=head1 NAME

sqltree - hierarchical data (tree) implementation in SQL

=head1 SYNOPSIS

  sqltree [DRIVER] [TABLE] [PK] [PARENT] [TYPE]

=head1 VERSION

0.0.5_2 (2013-06-12)

=head1 DESCRIPTION

B<sqltree> generates the SQL for a herarchical data (tree)
implementation using triggers, as described here:

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

This implementation relies on a previously-defined table containing:

=over

=item * a single primary key column

=item * a parent column that references the primary key

=item * a column to hold path data [optional]

=back

Several triggers are added to this previously-defined table, which
update a new table holding in-depth tree information.

Output from B<sqltree> can usually be piped directly to the "sqlite3"
or "psql" command line tools.

=head1 ARGUMENTS

All of these argument will be prompted for if they are not provided on
the command line.

=over

=item DRIVER

Must be 'SQLite' or 'Pg'. Patches for other database systems are
welcome.

=item TABLE

The name of the (existing) table holding the hierarchical data. The
additional tree table will be called "table_tree".

=item PK

The primary key column of the (existing) table holding the hierarchical
data.

=item PARENT

The parent column of the (existing) table holding the hierarchical
data.

=item TYPE

The SQL column type of the (existing) primary key and parent columns.

=back

=head1 OPTIONS

=over

=item --path

An existing column in TABLE into which the tree path will be
automatically calculated. This column should be defined as TEXT or
VARCHAR, and should be UNIQUE.

=item --path-from

Required when C<--path> is given to identify the existing column in
TABLE from which path names will be built.

=item --order

[NOT IMPLEMENTED] An existing column in TABLE containing the object
ordering information.

=back

=head1 SEE ALSO

L<App::sqltree>(3p)

=head1 AUTHOR

Mark Lawrence E<lt>nomad@null.netE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010,2013 Mark Lawrence E<lt>nomad@null.netE<gt>

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

