Fey::Schema - Represents a schema and contains tables and foreign keys
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:
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.
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
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
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
Returns all the foreign keys which reference the specified table. The table can be specified as a name or a
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.
See Fey for details on how to report bugs.
Dave Rolsky <firstname.lastname@example.org>
This software is Copyright (c) 2011 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)