The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SQL::Entity::Relationship - Entities Relationship abstraction layer.

SYNOPSIS

    use SQL::Entity::Relationship ':all';
    use SQL::Entity::Column ':all';
    use SQL::Entity::Table;
    use SQL::Entity::Condition ':all';

    my $dept = SQL::Entity::Table->new(
        name    => 'dept',
        alias   => 'd',
        columns => [
            sql_column(name => 'deptno'),
            sql_column(name => 'dname')
        ],
    );
    my $emp  = SQL::Entity->new(
        name                  => 'emp',
        primary_key               => ['empno'],
        unique_expression     => 'rowid',
        columns               => [
            sql_column(name => 'ename'),
            sql_column(name => 'empno'),
            sql_column(name => 'deptno')
        ],
    );
    $emp->add_to_one_relationships(sql_relationship(
        target_entity => $dept,
        condition     => sql_cond($dept->column('deptno'), '=', $entity->column('deptno'))
    ));

DESCRIPTION

Represents relationship between entities.

EXPORT

sql_relationship by all tag.

ATTRIBUTES

name

Name of the relationship

target_entity
condition
join_columns
order_by

METHODS

initialise
join_condition

Return join condition.

join_condition_as_string

Return SQL condition fragment.

join_columns_values

Returns join columns values.

join_columns_condition

Returns condition for join columns.

order_by_clause

Returns order by sql fragment.

associate_the_other_end

Associated the other end.

sql_relationship

Creates a new relation object.

SEE ALSO

SQL::Entity SQL::Entity::Column

COPYRIGHT AND LICENSE

The SQL::Entity::Relationship module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

AUTHOR

Adrian Witas, adrian@webapp.strefa.pl