I highly recommend this book for anyone who finds he or she needs to learn either MySQL or a programming API for a relational database.
MySQL is an open source relational database that has found its way into the back-end of many web servers, particularly those running on Linux through the Apache Server. MySQL can be queried directly, in an ISQL session, or via any of a number of APIs. DuBois book covers the basics of the C, PHP, and Perl APIs, and there is a robust C++ API available from the MySQL web site, but this book does not cover that. The particular appeal of MySQL for web development is in its small footprint and incredibly fast retrieval of data. It is most appropriate for enterprises that do a low level of table updates and insertions and a high level of data retrieval.
Paul DuBois's "MySQL" is one of the best technical books I have read on any subject. When prototyping a web-based application, I was able to get from nothing to a working, on-line application in two weeks through the use of this book. From this I was able to develop a full application within a month. For that particular application, I used PHP, as it provided the "best fit" for my needs. In my current job, I find that I need to do much higher levels of administration, including moving image files into tables, updating relationships between the image tables and their interfaces, and retrieving the images from the database on demand. For much of this work, I now use the C and C++ APIs. DuBois's book eased the transition for these tasks quite smoothly.
The book is divided into a progressive walk through MySQL. Part I introduces the reader to SQL and MySQL in particular. It begins with a tutorial chapter, then advances to the basics of MySQL, covering in turn basic data types, syntax, and optimisation. Part II discusses programming interfaces. One of the better aspects of this is a general discussion of choosing the appropriate API for the programmer's task. Separate chapters are devoted to C, PHP, and Perl. Part III covers SQL administrative tasks. Finally, Part IV contains a set of appendices, which, in my case is the most used section of the book on a day-to-day database administrator basis.
Since this review is written for C Vu, I will focus the balance of my attention on this section.
DuBois approaches all of the APIs that he covers from a foundation of good programming principles, beginning from the point of reducing code redundancy. Wherever feasible, code that will be used by multiple applications is put into a common header. "Magic numbers" (or strings) never appear in his examples. For instance, all basic database initialization handles (host name, user name and password, and database name) are defined at the preprocessor level. For an initial cut, the user passes these in with the command. DuBois shows how these can be set globally in more secure environments.
The section on the C API begins with a set of general requirements. Specific mention of the MySQL C header files and client libraries provides the reader with how to determine if they exist, and how to obtain and compile them in if they do not.
One aspect of DuBois's treatment that I particularly appreciate is his coverage of how to compile and link programs into working executable code. All too frequently, books on programming leave the task of learning how to compile up to the reader. Of course, the drawback here, is a need to focus attention on one primary compiler. In this case (happily for me), it is the one I use the Gnu C compiler, gcc. The choice is justified for this topic, as the book is primarily dedicated to the Unix platform. However, sections on compiling for Windows users are appended, though not covered in the same depth.
Something that has been stressed in the c.l.c.m, and c.l.c++.m newsgroups is defining the declaration of the main() function to return an int. DuBois follows this practice. The one complaint that readers of C Vu might have with DuBois is that he uses an exit(0); rather than a return 0; upon successful completion of the main function.
DuBois pays considerable attention to a complete treatment of error checking, and defines how to return meaningful error messages when a program encounters an error. Again, global errors are treated in a header file (this in the third C example in the chapter), and all subsequent examples include this header, called, quite sensibly common.h.
Once the preliminaries are out of the way, DuBois turns to specific database manipulations such as insertions, updates, and queries. Beyond these, he discusses the tradeoffs of various database methodologies and provides users with the tools necessary to decide themselves. The section ends with an interactive query-processing example, and closes with a section of Miscellaneous Topics, which treats in one place the common mistakes that the client programmer should avoid.
In the appendices, DuBois includes a reference to the C API functions. Here again, the experienced database programmer will find the most use in the Appendix.
Finally, what particularly appeals to me about DuBois's book is that, beyond the attention to solid programming principles, is the absolute clarity of his prose. This is a book I have read a couple of times, and continue to learn something new with each perusal of a topic. His writing can be absorbed at any of numerous levels novice, intermediate, and advanced. After nearly a year as a database administrator, I find the writing addresses topics clearly, without either condescension or over-simplification. This is no small feat.
I highly recommend this book for anyone who finds he or she needs to learn either MySQL or a programming API for a relational database. While the book is dedicated to MySQL, its lessons can be applied to other RDBMS products as well. I either recommend it or actually purchase a copy for any new employee who will be working with me on our database maintenance.