Alzabo::RDBMSRules - Base class for Alzabo RDBMS rulesets
use Alzabo::RDBMSRules; my $rules = Alzabo::RDBMSRules( rules => 'MySQL' );
This class is the base class for all Alzabo::RDBMSRules modules. To instantiate a subclass call this class's new method. See the "SUBCLASSING Alzabo::RDBMSRules" section for information on how to make a ruleset for the RDBMS of your choice.
Alzabo::RDBMSRules
new
A list of names representing the available Alzabo::RDBMSRules subclasses. Any one of these names would be appropriate as the rdbms parameter for the Alzabo::RDBMSRules->new method.
rdbms
Alzabo::RDBMSRules->new
rdbms => $rdbms_name
The name of the RDBMS being used.
Some subclasses may accept additional values.
A new Alzabo::RDBMSRules object of the appropriate subclass.
Alzabo::Create::Schema
A list of SQL statements.
Alzabo::Create::Index
Alzabo::Create::Table
new => Alzabo::Create::Schema object
old => Alzabo::Create::Schema object
Given two schema objects, this method compares them and generates the SQL necessary to turn the 'old' one into the 'new' one.
An array of SQL statements.
new => Alzabo::Create::Table object
old => Alzabo::Create::Table object
Given two table objects, this method compares them and generates the SQL necessary to turn the 'old' one into the 'new' one.
The following methods are not implemented in the Alzabo::RDBMSRules class itself and must be implemented in its subclasses.
A list of valid column type specifiers.
Given a string defining a feature, this method indicates whether or not the given RDBMS supports that feature. By default, this method always returns false unless overridden in the subclass.
Features that may be asked for:
extended_column_types
Column types that must be input directly from a user, as opposed to being chosen from a list. MySQL's ENUM and SET column types are examples of such types.
index_column_prefixes
MySQL supports the notion of column prefixes in indexes, allowing you to index only a portion of a large text column.
fulltext_indexes
This should be self-explanatory.
Alzabo::Schema
A boolean value indicate whether the object's name is valid.
Alzabo::Exception::RDBMSRules
Alzabo::Create::Column
A canonized version of the type.
column => Alzabo::Create::Column object
attribute => $attribute
This method is a bit different from the others in that it takes an existing column object and a potential attribute.
A boolean value indicating whether or not this attribute is acceptable for the column.
Returns a boolean value indicating whether or not the given column can be part of its table's primary key.
Given a column object, indicates whether or not the column can be sequenced.
A boolean value indicating whether or not the index is valid.
Alzabo::Create::ForeignKey
new => Alzabo::Create::Column object
old => Alzabo::Create::Column object
Given two column objects, this method compares them and generates the SQL necessary to turn the 'old' one into the 'new' one.
new => Alzabo::Create::Index object
old => Alzabo::Create::Index object
Given two index objects, this method compares them and generates the SQL necessary to turn the 'old' one into the 'new' one.
new => Alzabo::Create::ForeignKey object
old => Alzabo::Create::ForeignKey object
Given two foreign key objects, this method compares them and generates the SQL necessary to turn the 'old' one into the 'new' one.
Given two table objects, this method compares them and generates the SQL necessary to give change the primary key from the 'old' one's primary key to the 'new' one's primary key.
Given a schema object (which presumably has no tables), this method uses the schema's Alzabo::Driver object to connect to an existing database and reverse engineer it into the appopriate Alzabo objects.
Alzabo::Driver
To create a subclass of Alzabo::RDBMSRules for your particular RDBMS is fairly simple.
Here's a sample header to the module using a fictional RDBMS called FooDB:
package Alzabo::RDBMSRules::FooDB; use strict; use vars qw($VERSION); use Alzabo::RDBMSRules; use base qw(Alzabo::RDBMSRules);
The next step is to implement a new method and the methods listed under the section "Virtual Methods". The new method should look a bit like this:
1: sub new 2: { 3: my $proto = shift; 4: my $class = ref $proto || $proto; 5: my %p = @_; 6: 7: my $self = bless {}, $self; 8: 9: return $self; 10: }
The hash %p contains any values passed to the Alzabo::RDBMSRules->new method by its caller.
Lines 1-7 should probably be copied verbatim into your own new method. Line 5 can be deleted if you don't need to look at the parameters.
The rest of your module should simply implement the methods listed under the "Virtual Methods" section of this documentation.
Look at the included Alzabo::RDBMSRules subclasses for examples. Feel free to contact me for further help if you get stuck. Please tell me what database you're attempting to implement, and include the code you've written so far.
Dave Rolsky, <dave@urth.org>
To install Alzabo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Alzabo
CPAN shell
perl -MCPAN -e shell install Alzabo
For more information on module installation, please visit the detailed CPAN module installation guide.