MySQL Cookbook
by Paul DuBois
Published by O'Reilly & Associates, Inc.
Review by Nelson Bigelow, Jr.,
MELUG-Central
a division of
MELUG - MainE Linux Users Group
What is MySQL? It is a database management system. Why would I want to use it rather than
some other product? As the preface of the book says, "MySQL is fast, and it's easy to set up,
use, and administrate" (p. xv). It can be installed on many platforms from Unix to Windows and
Macs, and of course, on Linux. It uses SQL (Structured Query Language) to access the data, but
does not provide any programming capabilities such as decision-making or looping. These are
supplied by other programming languages. MySQL can be obtained from the web site
http://www.mysql.com/.
Access to MySQL by other languages is through an API (application programming interface).
The most common languages for which an API is available are C, C++, Java, Pascal, Perl, PHP,
Python, an others. For more information on APIs, visit the web site
http://www.mysql.com/portal/develpment/html/. You might also visit the web site of your
favorite language, as I did. I discovered that there is a lot of information for my language of
choice, PowerBASIC, on its web site, http://www.powerbasic.com/. I found the APIs for Perl
also on http://www.perl.org/ and http://cpan.perl.org/.
The approach taken in presenting the material is "a problem-and-solution format" (p. xv), thus its
title "MySQL Cookbook." Each topic is a Problem followed by a short statement of the
Solution. The Solution is then expanded in the Discussion section. These explanations are well
written, as well as informative and instructive. All are intended for immediate use in your
projects.
Many of the Discussion sections embody code that allows you to interact with MySQL using its
own command language. Other Discussions include source code (scripts) written in the
languages that were chosen for this book, Perl, PHP, Python, and Java. These perform functions
that are not available in SQL. These languages are available on the Web. (URLs are given in
Appendix C.).
Sample data used in the examples are also available. These include the text of the King James
Bible, used in the Chapter 4, "Working with Strings," and a baseball database. The source code
for the recipes and the Bible are available from http://www.kitebird.com/mysql-cookbook/, and
the baseball database from http://baseball1.com/.
In this book, you'll find everything you need to build and manage databases, whether stand-alone
or on a network. You don't need a network to use it however, because the server can be run on
the same machine that hosts the client. The server can handle multiple clients simultaneously.
Several of the many topics which I run into a lot are modifying tables and importing data. In
many data systems these are inadequately covered, but here they are given extensive treatment.
These are::
      a. Modifying tables (about 20-pages). For example, you can drop, add, or reposition a
column or change its definition or its name.
      b. Importing and exporting data from other databases (about 100-pages). Common
formats accepted are tab-delimited and CSV (comma-separated values). Most databases can
export in one of these formats, so you can move to MySQL from them. Data can be exchanged
between MySQL and Microsoft Access, Microsoft Excel, or FileMaker Pro.
Close to 20% of the book (200-pages) is devoted to using MySQL on the Web, from generating
Web pages to running scripts on Apache and Tomcat servers. You can process queries and
receive data from web pages as well as handle the many other aspects of Web programming,
including sessions.
Three appendixes round out the volume. The first gives all the Internet sources where you can
obtain MySQL, source code for the recipes, and APIs for the four languages that are used in the
book. The second appendix is a JavaServer pages overview and a Tomcat server primer. The
final appendix is a list of resources, both books and web sites, for MySQL, the four languages,
Apache, and several other topics.
When you first approach this book, you may be intimidated. It's just short of 1000-pages, and
packed with technical information, much of which may be unfamiliar. But the problem-solution
format makes it easy to work with, like your kid's lunch, which you have to cut up in little
pieces. Even if you're not familiar with SQL or any of the languages, this is a good place to
learn.
If you are working with MySQL, you need this book. It provides solutions to many specific
problems that you may encounter daily when working with data. You will save many hours by
turning to it for answers.
If you are thinking of moving to MySQL, this book will give you an intensive overview. With it
you can then decide whether MySQL is the product for you.
MySQL Cookbook is the First Edition, dated October 2002, ISBN 0-596-00145-2.. It covers
MySQL version 4.0, which is the version that you will download from http://www.mysql.com/.
The cost is $49.95, but can be obtained from http://www.oreilly.com/ with a 20% discount for
user-group members. You need a discount code, which we have. It also qualifies for free
shipping and handling.
As a database user, developer, and maintenance consultant of many years, I found this book
endlessly fascinating. I've learned a lot from it, and there's more to learn. I heartily recommend
it for all who are already involved with or plan to become involved with MySQL.