MySQL Cookbook 64
Michael J. Ross writes "Of all the technical challenges faced by the typical experienced computer programmer, questions about syntax form a relatively small portion. This is especially true now that current coding editors and IDEs offer statement expansion and syntax checking. Rather, the most common type of technical challenge is understanding how to solve a specific data access or manipulation problem. Hence the growing popularity of programming "cookbooks," which are filled with "recipes," each comprising a concise statement of a focused problem, followed by a solution, with plenty of sample code to show how to implement it. For developers using the MySQL database system, the gold standard of such books is MySQL Cookbook, by Paul DuBois." Read below for the rest of Michael's review
MySQL Cookbook | |
author | Paul DuBois |
pages | 948 |
publisher | O'Reilly Media |
rating | 8 |
reviewer | Michael J. Ross |
ISBN | 059652708X |
summary | A great book for developers using the MySQL database system |
Published by O'Reilly Media, the second edition appeared in November 2006. This new edition has been updated for MySQL version 5.0. The publishers have a Web page devoted to the book, where the visitor can find both brief and full descriptions of the book, an online table of contents and index, a sample chapter (number 5, "Working with Strings") in PDF format, errata (none reported as of this writing), and a way to post your own review on the O'Reilly Web site. There are also links for purchasing the book, or reading an online version, in the Safari Bookshelf program.
The bulk of the book's material is divided among 20 chapters, covering a wide range of topics: Using the mysql Client Program; Writing MySQL-Based Programs; Selecting Data from Tables; Table Management; Working with Strings; Working with Dates and Times; Sorting Query Results; Generating Summaries; Obtaining and Using Metadata; Importing and Exporting Data; Generating and Using Sequences; Using Multiple Tables; Statistical Techniques; Handling Duplicates; Performing Transactions; Using Stored Procedures, Triggers, and Events; Introduction to MySQL on the Web; Incorporating Query Results into Web Pages; Processing Web Input with MySQL; Using MySQL-Based Web Session Management.
Most of these chapters contain a generous number of sections, each serving as a recipe for a specific problem within MySQL. Two of the chapters have only four such recipes, but most have a dozen or more, with a few of them boasting more than three dozen recipes. Each recipe begins with a brief problem statement, and usually an equally brief solution statement, followed by a much more lengthy discussion, which contains the actual explanation of the solution, the sample code, and the expected output of that code. Some of the sections conclude with a mention of related recipes that could also be consulted.
This book, like so many other programming cookbooks, is weakened by the practice of offering a "Solution" subsection that consists of only one or two sentences — so terse and high-level that it provides, for all practical purposes, no solution to the reader. The actual solution is found in the "Discussion" subsection, which follows. This practice makes no sense. Because both subsections address the problem solution, they should be combined into a single subsection, naturally labeled "Solution." It appears that the purpose of the current Solution statements is to provide a terse summary. If so, then it should be labeled as such, yet still included within the new Solution subsection.
Despite this illogical division of each solution into two subsections, the content of the problem solutions found in MySQL Cookbook should be quite valuable, for several reasons: Firstly, the author has chosen the sorts of problems, within each category, that the MySQL programmer would typically encounter. No doubt this is a consequence of Paul DuBois being the author of a number of MySQL books, as well as one of the earliest contributors to the online MySQL Reference Manual. Secondly, the solutions work, and have been demonstrated to do so. Thirdly, the writing style is straightforward, which is characteristic of O'Reilly's titles. Fourthly, all of the problem solutions contain sample code and its output, which not only demonstrate the validity of each solution (as noted in my second point), but also allows the reader to see how the solution works simply by reading the material, and not having to type in the sample code to get the output within their own development environment — assuming one is even at hand, when reading the book.
The bulk of MySQL-related code in use today, was created not just to be accessed within a database client program, such as mysql, but instead from interpreted programming languages — especially those used heavily on Web sites. This is one area where MySQL Cookbook really shines, because it contains a large amount of sample code in Perl, PHP, Python, Java, and even Ruby. That is not to say that every code sample in one language has corresponding samples for all of the other languages; that would undoubtedly make the book much longer than it currently is, and probably unwieldy. But in cases where all of the languages are capable of expressing brief solutions, then they are included.
Regardless of whether the reader chooses the print or online versions, there are roughly two ways to make use of this book. If a programmer wishes to significantly increase their knowledge of what MySQL can do for them, and also increase their comfort level with utilizing those capabilities, then they might elect to read the book from stem to stern. Given that this would involve reading over 900 pages, it would certainly take some time for the average developer, but arguably could be time well spent. At the other end of the spectrum, the reader might elect to peruse individual sections that look interesting — particularly if they are relevant to a current project. This approach is certainly doable, because each of the recipes is self-contained, without the cross-referencing seen in many non-recipe style books. Admittedly, there are some "See Also" sections, but they are relatively few in number, with largely optional information, and tend to simply enrich the book's presentation, rather than frustrating the reader by pointing to other areas of the book.
This new edition of MySQL Cookbook concludes with four appendices, and an index. The first appendix explains where to obtain the software for MySQL, the five API programming languages used in the book, and the Apache Web server. The second appendix shows how to execute programs written in those five interface languages, on the command line. The third appendix is a fairly substantial primer on Java Server Pages (JSP) and Tomcat, providing an overview of servlets and JSP, as well as how to install and set up a Tomcat server, the Tomcat directory structure, the basics of JSP pages, and more. The last appendix lists resources outside the book for MySQL and the five aforementioned languages.
Unlike far too many programming books on the market now, this book's index is generally quite thorough, which is essential for a work of this size (975 pages). The recipe titles in the table of contents, are detailed enough to make it possible for the reader to locate the appropriate recipe in the book for their particular problem — assuming the book addresses that problem — and are grouped by subject, making it easier to find related recipes, which oftentimes can provide insight into other problems that they do not address directly.
Despite the obvious effort that has gone into both editions of this book, there are still some areas for improvement, and most of them are related to the readability of the sample code. Admittedly, there are different schools of thought as to optimal coding style, including use of whitespace, the placement of braces, and other matters. This assessment can only be my own opinion, based upon years of reading other people's code. The sample code in MySQL Cookbook would be more readable if more whitespace were utilized to separate function and variable names from open and close parentheses. This is especially true for the SQL code and MySQL extensions, for which all of the keywords are in all uppercase. The code fragments and full programs written in the API languages — such as Perl and PHP — are more readable, though they sometimes suffer from nondescriptive variable names. One might argue that the aforesaid choices are needed to cut down on the space consumed by the code on the book's pages. But if that were true, then the author likely would not have wasted an entire line for each open brace. Last, and certainly not least for the programmer who would like to try out the author's sample code in their own environment, it is unfortunate and inexplicable as to why the sample code is not offered on the O'Reilly Web site for downloading.
All in all, MySQL Cookbook is a well-organized and neatly written work, which should be of tremendous value to any software developer trying to find proven solutions to common database programming problems.
Michael J. Ross is a Web consultant, freelance writer, and the editor of PristinePlanet.com's free newsletter. He can be reached at www.ross.ws, hosted by SiteGround.
You can purchase MySQL Cookbook from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Cookbooks take em or leave em they're OK (Score:3, Informative)
I had a chance to skim through the MySQL cookbook a week or so ago and will more than probably pick one up, though I think I need another shelf for my web development/linux books.
irCertaninly the ORielly programming series are very nice books indeed. Not quite used to their Linux OS books yet from them, the Wiley ones are more approachable.
Re: (Score:3, Insightful)
I find these cookbooks more useful with things like PHP and Linux. Although I'm sure there are some good nuggets of information in this cookbook.
Safari (Score:1)
I'd recommend trying their online library [oreilly.com], which most certainly contains this book as well as about 10000 others on a wide variety of subjects, ATM. I used Safari last month and it was really amazing!! I plan on renewing my subscription when I have more reading time...
Re: (Score:2)
* Dynamic HTML: The Definitive Reference, 2nd Edition
* JavaScript: The Definitive Guide, 4th Edition
* Programming PHP
* Web Database Applications with PHP & MySQL
* PHP Cookbook
* Webmaster In a Nutshell
inane introductions (Score:2)
Re: (Score:1)
Semantics is unknown to many programmers (Score:2)
Not this kind of cook book? (Score:2, Funny)
Re: (Score:2)
Re: (Score:1)
This recipe is missing (Score:5, Interesting)
I noticed there was a recipe which I'd like to see which was not covered. Is there a recipe for don't treat my data as garbage by default?
It was brought up in a reply [slashdot.org] to a comment here on Slashdot by Marten Mickos, CEO, MySQL AB. I've not heard if they managed to help out the people who are effectively forced into using MySQL but would rather not.
Re: (Score:2)
Re: (Score:2)
A snippet from the post in question:
Where's the recipe for fixing that problem?
Re: (Score:2)
Where's the recipe for fixing that problem?
it's right in the reply [slashdot.org]: use InnoDB by default. or how about this, don't forget to set the transaction flag. it's not rocket science and these aren't valid complaints either. it's just mindless MySQL bashing because "it doesn't work as I expect it to by default and I can't be bothered to tune".
Too funny (Score:1, Troll)
Re: (Score:2)
And you thought the morning erection of the Slashdot male was caused by what, women?
Re: (Score:2)
I was pretty sure it was pressure on the bladder brought on by consumption of too much jolt, bawls, or mountain dew in the waking hours.
Sample Code Delays (Score:1)
It usually takes a couple of weeks for authors to re-enter society to the extent that they can extract the sample code and massage it into a releasable form. (For me it takes months, but I'm a bad example.) I assume that's what happened here.
Re: (Score:1)
http://www.kitebird.com/mysql-cookbook/downloads-
Re: (Score:1)
Yes; the book preface mentions that. We're working on either hosting the code on our site too or pointing to Paul's page from our catalog page.
Paul, are you well? Update the errata! (Score:1)
Paul, your writing is first rate and I love everything about your books. I hope you are well--and get the errata updated soon, please.
BTW: Paul literally w
Re: (Score:1)
Thanks for collecting the errata. Could you post it to the errata page [oreilly.com]? That way, it will go through "the system" (we'll forward it to Paul, he's say yea or nay, and the changes will make their way into a future reprint).
Re: (Score:2, Informative)
So, yeah, *I* can make the *effort* and take the *time* to do so, but I have to wonder "Why bother?" when no action is being taken to keep the pages up to date
Re: (Score:1)
We're actually in the middle of a systems overhaul for errata -- to provide faster response, quicker updates to electronic versions of content (current processes are unfortunately still tied to print-based workflow triggers), and a more useful interface for viewing errata. Unfortunately, that's meant temporarily diverting attention from processing current errata submissions. We're working through the backlog, but there will likely be delays for at least a few more weeks. We do track all errata subm
Re: (Score:2)
Re: (Score:1)
Re: (Score:1)
Re: (Score:1)
another "idea" (Score:3, Insightful)
Hence the growing popularity of programming "cookbooks," which are filled with "recipes," each comprising a concise statement of a focused problem, followed by a solution, with plenty of sample code to show how to implement it.
Of course, another option is to learn the "fundamentals" and "theory" of data management, so that you can "understand" data management at a more "abstract" and "fundamental" level, instead of relying on "cookbooks" and "recipes" that you can copy mindlessly. Then you can save "money" on "cookbooks" when the "next big thing" comes around, because you already "know" that it's the "same thing" with "different syntax".
Imagine a "heart surgery cookbook" for newbies? A "bridge designing cookbook"? An "accounting cookbook"? What do you think of surgeons, engineers, or accountants who carry those around, tucked under their arm?
On the other hand, it's quite "profitable" for "consultants" like "me" to come in a clean up the "garbage" that the "cookbook"-using "idiots" "write".
(I guess all the "quotes" are a nod to MySQL's ability to accept strings in place of other types? Is there a recipe to fix that?)
Re: (Score:3, Informative)
For example, whats efficient in MySQL, isn't whats efficient in SQL Server, and vice versa. That makes for extreme differences in whats the best architecture and best practices between environments. It tends to be extremely visible in "
Re: (Score:2)
Re: (Score:3, Interesting)
Distributed applications: RMI in Java, C++, or
Re: (Score:1)
Do they? A design pattern is an abstract, theoretical, generic approach to a solution. A recipe is a concrete solution to a specifc problem.
Sounds like they're cribbing code, not applying patterns.
Re: (Score:2)
Abstract, yeah. Generic, yes. Theoritical? Hell freagin no. Design patterns are practical way of solving -implementation- problems. That implementation will differ accross environments.
Best example in the book: The Observer pattern. In C++ or Java, you implement it "by the book". In
Or some design patterns are solutions
Re: (Score:2)
Typical: Evan, can you "update" the web pages with the information I've attached below?
What, do you want me to update it or not? Is this a joke?
Some people learn by example (Score:2, Insightful)
Concerns over the (dubious) trustworthiness of MySeQueL to hold your precious data aside, a good recipe can prove invaluable for reasons besides making sure you're not forgetting anything.
I'm an engineer. At some stage, you have to understand th
Re: (Score:2)
At which point you'd be horrified at the way MySQL "handles" data and how the query "optimizer" really deserves to have the quotes around it, so much so that you'll be begging to use a database that offers more than really fast SELECTS on a single table.
Re: (Score:2)
I'll give it a 3/5 (Score:2, Interesting)
There's very little on subselects-- in fact, in trying to provide a page count, I can't find subselect i