Page 243 - DCAP402_DCAO204_DATABASE MANAGEMENT SYSTEM_MANAGING DATABASE
P. 243
Database Management Systems/Managing Database
Notes 14.2.4 The DBI Module
The DBI Module is an incredibly useful tool because it abstracts away the need to learn how to
communicate with every type of database out there. Consider what a pain it would be if you had
to write a CGI script for every proprietary database engine.
Now imagine how much extra work you would have if the management decided to change
database vendors on you after you had already written your code!
What the DBI module does for you is to provide a single interface to send SQL commands to any
proprietary database. Essentially, you write all your code to a generic standard, and move it
from database to database without having to re-code your application.
The secret to the DBI module is the extensive library of DBD (Database Dependent) modules that
come with the standard distribution of Perl 5. These DBD modules provide the code that hooks
up DBI to a proprietary database driver.
Of course, since these DBD modules are already written for almost any Database you would
consider using, you needn’t do any of that hard work. All you need to worry about is satisfying
the requirements of the DBI interface. Everything else is handled behind the scenes.
It looks pretty complex but believe me, it isn’t. And it makes your life as a programmer incredibly
easy. That is, although the communication takes place through so many actors, you, as the
programmer, need not bother with the details of that communication. You talk to the DBI
module, and the DBI module handles the multitude of proprietary database blue meanies by
itself.
236 LOVELY PROFESSIONAL UNIVERSITY