decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books
Your contributions keep Groklaw going.
To donate to Groklaw 2.0:

Groklaw Gear

Click here to send an email to the editor of this weblog.


To read comments to this article, go here
Review of Russell Dyer's MySQL in a Nutshell, Second Edition
Wednesday, September 24 2008 @ 07:21 AM EDT

Review of MySQL in a Nutshell, Second Edition
~ reviewed by Steve McInerney

MySQL in a Nutshell, Second Edition
By Russell Dyer
Second Edition April 2008
Pages: 564
Series: In a Nutshell
ISBN 10: 0-596-51433-6 | ISBN 13: 9780596514334
http://oreilly.com/catalog/9780596514334/

I originally reviewed MySQL in a Nutshell, the first edition, in July 2005, but with the Second Edition released in April, it seemed worth taking another look. The first thing I noticed is that, compared to the First Edition, the second is about 40% bigger. But is it just extraneous fluff or useful information?

Useful. Very.

The introduction in the First Edition was and is an excellent starter, the Second Edition applies just a light polish of changes. It is an improvement, but more subtle.

Part II of the Second Edition is the SQL Statements Reference. This is where I'd suggest the bulk of Russell's efforts went. Again, the First Edition was good. The Second is better. To demonstrate the improvement I see, here's a link to an example on Russell's website where he compares the First Edition view of the MAX() function with the Second Edition view.

First Edition:

MAX(column)

Returns the lowest number in the values for column. Used in conjunction with GROUP BY clause.

SELECT col1, MAX(col2)
FROM table1
GROUP BY col1;

Second Edition:

MAX(expression)

This function returns the highest number in the values for a given column. It's normally used in conjunction with a GROUP BY clause specifying a unique column, so that values are compared for each unique item separately.

As an example of this function, suppose that we wanted to know the maximum sale for each sales person for the month. We could enter the following SQL statement:

SELECT 
  CONCAT(name_first, SPACE(1), name_last) AS rep_name, 
  MAX(sale_amount) AS biggest_sale
FROM sales
JOIN sales_reps USING(sales_rep_id)
  WHERE DATE_FORMAT(date_of_sale, '%Y%m') = 
        DATE_FORMAT(CURDATE(), '%Y%m')
GROUP BY sales_rep_id DESC;

We've given sale_amount as the column for which we want the largest value returned for each sales rep. The WHERE clause indicates that we want only sales for the current month. Notice that the GROUP BY clause includes the DESC keyword. This will order the rows in descending order for the values of the biggest_sale field: the biggest sale at the top, the lowest at the bottom.

I think you can start to see why the second edition is 40% larger.

In the First Edition everything in the SQL Reference was in pure alphabetical order. If you knew the type of thing you wanted to do, but couldn't recall the exact command, it could be a pain to find it. The Second Edition logically groups statements, e.g., Chapter 11: String Functions; Chapter 12: Date and Time Functions. A nice touch that can make a big difference.

As for the meat of the SQL Reference? Generally minor but welcome improvements to the details of SQL Syntax. For example: Exporting SELECT results has gone from ~ ¾ of a page to 1½ pages. Again it is useful information, not filler. An additional improvement I found most welcome was with the examples. Beyond just “here's an example”, it also tells you what to expect as output from running the various commands.

Let me show you what I mean. Here's part of the explanation from DROP USER:

Some users may have more than one user account (i.e., user and host combinations). You should check the server's mysql.user table to be sure:
SELECT User,Host
FROM mysql.user
WHERE User LIKE 'paola';

+-------+--------------+
| User  | Host         |
+-------+--------------+
| paola | localhost    |
| paola | caporale.com |
+-------+--------------+

DROP USER 'paola'@'localhost',
  'paola'@'caporale.com';

What I like about this particular example is that it shows an edge case, something a little unusual from the expected day-to-day use of DROP USER. Further, it demonstrates how you deal with the edge case. This is, in my opinion, where many technical books can be a let down, in that they only cover the simple cases.

My biggest gripe with the first edition was that it was aimed at developers. It didn't cater well to Sysadmins or DBAs. Speaking as a sysadmin, you could use the First Edition, but you needed something else to cover the gaps. So I'm delighted to say that the Second Edition well and truly fixes this issue. The various tools one uses are explained in greater and clearer detail than the man pages and what online documention I've previously used. It's still perhaps not as complete as I'd like, but from having used it at work to solve issues, I found it sufficient to the task. I suspect my wish list would add another 40% again to the book size.

There is a brand new chapter on Replication, and it appears to more than cover all the issues one could expect to deal with. If it was a simpler topic, I'd suggest it was too much, but given the complexities with replication, it's likely just right.

The one oddity I did observe is that Data Types and Operators are Appendixes. This is more of a personal, dare I say emotional, feeling, though, rather than true criticism. The information is there. It's easily findable.

But I would stress, as with all the Nutshell series, this Second Edition of MySQL in a Nutshell is emphatically a reference guide. It is not a general purpose teaching or learning book. You won't find, easily, the differences between InnoDB or MyISAM and why you could or should choose one over the other1. But you will find HOW to use one or the other.

All up, this is an excellent improvement on the First Edition. It polishes where the first was already good and noticably improves on those areas that the first let down.

Pamela asked Russell if he had any words he'd like to add:

For the last three years I have used the first edition extensively and made plenty of notes in the margins of changes to the software so that I would be ready when I wrote the second edition.

In fact, when I left my home town of New Orleans after Hurricane Katrina, all I took with me was a small bag with about four days of clothes, a toothbrush, my laptop computer, and this annotated copy of my book.

When I began the second edition, I used my marked up copy, and I read through all of the reviews (yours included) and many web log comments. I tried to incorporate everyone's ideas and suggestions for improvements and address their negative criticisms. The best and most frequent comments I received, though, were related to my examples: readers felt that the examples given were realistic and much easier to understand than those of other books on MySQL. I decided that that was my advantage, and while I had some good practical examples for many SQL statements and functions, I didn't have examples for all, and I felt that many were lacking. So, for the second edition I set a policy to provide realistic examples for all of them.

The result is a book that I feel is much more useful and a book of which I'm very proud. -- Russell Dyer, 29th June 2008.


1 I looked. I was asked this very question recently. It seemed like an appropriate test to apply to a Nutshell book.


  View Printable Version


Groklaw © Copyright 2003-2013 Pamela Jones.
All trademarks and copyrights on this page are owned by their respective owners.
Comments are owned by the individual posters.

PJ's articles are licensed under a Creative Commons License. ( Details )