Fey::Schema - Represents a schema and contains tables and foreign keys
version 0.38
my $schema = Fey::Schema->new( name => 'MySchema' ); $schema->add_table(...); $schema->add_foreign_key(...);
This class represents a schema, which is a set of tables and foreign keys.
This class provides the following methods:
my $schema = Fey::Schema->new( name => 'MySchema' );
This method constructs a new Fey::Schema object. It takes the following parameters:
Fey::Schema
name - required
The name of the schema.
Returns the name of the schema.
Adds the specified table to the schema. The table must be a Fey::Table object. Adding the table to the schema sets the schema for the table, so that $table->schema() returns the correct object.
Fey::Table
$table->schema()
If the table is already part of the schema, an exception will be thrown.
Remove the specified table from the schema. Removing the table also removes any foreign keys which reference the table. Removing the table unsets the schema for the table.
The table can be specified either by name or by passing in a Fey::Table object.
Returns the table with the specified name. If no such table exists, this method returns false.
When this method is called with no arguments, it returns all of the tables in the schema. Tables are returned in the order with which they were added to the schema.
If given a list of names, it returns only the specified tables. If a name is given which doesn't match a table in the schema, then it is ignored.
Adds the specified to the schema. The foreign key must be a Fey::FK object.
Fey::FK
If the foreign key references tables which are not in the schema, an exception will be thrown.
Removes the specified foreign key from the schema. The foreign key must be a Fey::FK object.
Returns all the foreign keys which reference the specified table. The table can be specified as a name or a Fey::Table object.
Returns all the foreign keys which reference both tables. The tables can be specified as names, Fey::Table objects, or Fey::Table::Alias objects. If you provide any aliases, the foreign keys returned will contain columns from those aliases, not the real tables. This provides support for joining an alias in a SQL statement.
Fey::Table::Alias
See Fey for details on how to report bugs.
Dave Rolsky <autarch@urth.org>
This software is Copyright (c) 2010 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0
To install Fey, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fey
CPAN shell
perl -MCPAN -e shell install Fey
For more information on module installation, please visit the detailed CPAN module installation guide.