Terrence Brannon
2005-04-09 15:41:11 UTC
What is a SQL Phrasebook?
A Perl module which separates SQL from your Perl code, making it
accessible via a unique piece of keyed text. Think of it as
Locale::KeyedText for relational databases.
Why would I need a SQL Phrasebook
* Better software engineering
Good software is designed in a DWIM fashion, where you spend time
doing what you mean as opposed to making repeated DWIS efforts. Any
large software project should not spend time defining sql in a
scalar and then accessing that scalar. This clutters your core code,
making it harder to follow, among other things. These tools provide
support for creating a separate library.
* Knowledge of tables accessed
It is important to know what tables are being accessed in your
project. This is important for numerous reasons. First, for
statistical purposes, highly accessed tables might need tuning.
Having all of your SQL in one place and having your code base
searchable for a single label simplifies the process of
understanding how your code is accessing tables. Second, if a table
changes, you need to know which SQL was using that table. Having all
the SQL in one place makes it easy to handle table changes.
* Testing
It is much easier to run model tests if all of your SQL is accessed
in the same fashion. It is also easier to group the tests by concept
if they can all be accessed via a unique label, e.g.:
my @auth_sql = qw/USER_ON_ID ROLE_FOR_ID PERMS_FOR_ID/;
my @order_sql = qw/ORDERS_TO_DATE ORDERS_THIS_MONTH/;
* Tuning
If a database expert can stare at all of the SQL for a project in
one place, it makes it easier for her to decide how to restructure
the entire SQL set.... or even more exciting, he might create
several SQL sets for different purposes and the Perl programmer can
haul in the appropriate SQL set tuned for his task, all without
modifying the Perl code!
* Reuse
You drop your SQL in the library once, use as many times as you want
List of SQL Phrasebooks
* SQL::Catalog by Terrence Brannon
* Class::Phrasebook::SQL by Rani Pinchuk
* Data::Phrasebook by Barbie
* DBIx::Librarian by Jason May
* SQL::Library by Doug Gorley
Modules with a larger purpose
* DBIx::SQLEngine by Matthew Simon Ryan Cavaletto
* Class::DBI/Ima::DBI
* DBIx::Recordset
ERRATA
This file is
<http://www.metaperl.com/article-pod/Catalog-sql_phrasebooks>
AUTHOR
Terrence Brannon, ***@metaperl.com
A Perl module which separates SQL from your Perl code, making it
accessible via a unique piece of keyed text. Think of it as
Locale::KeyedText for relational databases.
Why would I need a SQL Phrasebook
* Better software engineering
Good software is designed in a DWIM fashion, where you spend time
doing what you mean as opposed to making repeated DWIS efforts. Any
large software project should not spend time defining sql in a
scalar and then accessing that scalar. This clutters your core code,
making it harder to follow, among other things. These tools provide
support for creating a separate library.
* Knowledge of tables accessed
It is important to know what tables are being accessed in your
project. This is important for numerous reasons. First, for
statistical purposes, highly accessed tables might need tuning.
Having all of your SQL in one place and having your code base
searchable for a single label simplifies the process of
understanding how your code is accessing tables. Second, if a table
changes, you need to know which SQL was using that table. Having all
the SQL in one place makes it easy to handle table changes.
* Testing
It is much easier to run model tests if all of your SQL is accessed
in the same fashion. It is also easier to group the tests by concept
if they can all be accessed via a unique label, e.g.:
my @auth_sql = qw/USER_ON_ID ROLE_FOR_ID PERMS_FOR_ID/;
my @order_sql = qw/ORDERS_TO_DATE ORDERS_THIS_MONTH/;
* Tuning
If a database expert can stare at all of the SQL for a project in
one place, it makes it easier for her to decide how to restructure
the entire SQL set.... or even more exciting, he might create
several SQL sets for different purposes and the Perl programmer can
haul in the appropriate SQL set tuned for his task, all without
modifying the Perl code!
* Reuse
You drop your SQL in the library once, use as many times as you want
List of SQL Phrasebooks
* SQL::Catalog by Terrence Brannon
* Class::Phrasebook::SQL by Rani Pinchuk
* Data::Phrasebook by Barbie
* DBIx::Librarian by Jason May
* SQL::Library by Doug Gorley
Modules with a larger purpose
* DBIx::SQLEngine by Matthew Simon Ryan Cavaletto
* Class::DBI/Ima::DBI
* DBIx::Recordset
ERRATA
This file is
<http://www.metaperl.com/article-pod/Catalog-sql_phrasebooks>
AUTHOR
Terrence Brannon, ***@metaperl.com
--
Carter's Compass: I know I'm on the right track when,
by deleting something, I'm adding functionality.
Carter's Compass: I know I'm on the right track when,
by deleting something, I'm adding functionality.