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

Gear

Groklaw Gear

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


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
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.


  


Review of Russell Dyer's MySQL in a Nutshell, Second Edition | 183 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
Book review?
Authored by: Anonymous on Wednesday, September 24 2008 @ 07:31 AM EDT

I'm wondering if this review got cross-posted in the wrong place. Book reviews make sense on Groklaw when they have a legal/Free software licensing aspect.

A book on MySQL doesn't seem to have either.

(Of course, the site is PJ's, so she can post whatever she wants).

[ Reply to This | # ]

Corrections here
Authored by: SteveRose on Wednesday, September 24 2008 @ 07:44 AM EDT
Please indicate the correction in the title

---
The bars I'm admitted to, serve drinks. I expect Microsoft to always do what's
best for them - so I've trusted and relied upon Linux for years.

[ Reply to This | # ]

OT - off topic thread here
Authored by: Totosplatz on Wednesday, September 24 2008 @ 07:46 AM EDT
Please make links clicky.

---
Greetings from Zhuhai, Guangdong, China; or Portland, Oregon, USA (location
varies).

All the best to one and all.

[ Reply to This | # ]

Newspicks here
Authored by: SteveRose on Wednesday, September 24 2008 @ 07:50 AM EDT
Please quote part or all of the newspick in the title

---
The bars I'm admitted to, serve drinks. I expect Microsoft to always do what's
best for them - so I've trusted and relied upon Linux for years.

[ Reply to This | # ]

MAX() example is not an improvment
Authored by: Anonymous on Wednesday, September 24 2008 @ 09:22 AM EDT
It's supposed to be a reference for one function, not several at the same time.
The first edition example is short and sweet, and shows the context in which it
is used (I mean the usage example, not the entire MAX() reference text). The
second edition forces you to understand several other things also. It would be
good as an *extra* example, or in the body of text referenced from the function
reference. But as is, it is a good example of how not to 'improve' something.

[ Reply to This | # ]

Review of Russell Dyer's MySQL in a Nutshell, Second Edition
Authored by: Anonymous on Wednesday, September 24 2008 @ 10:01 AM EDT
The example in the first edition seems incorrect. I'd expect a "MAX"
function to return the highest value rather than the lowest.

[ Reply to This | # ]

in gamers terms
Authored by: Anonymous on Wednesday, September 24 2008 @ 01:01 PM EDT
you could use this max function to list
stats

and it could also be used in a business sense to see whom owes the most in an
order using a loop and such.

You could do a lot a neat things with such nice stuff.
Nice to see them getting detailed.

In a game development with mysql with no formal training is fun. books like that
are ALWAYS a big help.

[ Reply to This | # ]

Review of Russell Dyer's MySQL in a Nutshell, Second Edition
Authored by: mlwmohawk on Wednesday, September 24 2008 @ 02:41 PM EDT
Generally speaking, any book on MySQL should start out with a chapter or two on
why you should never use MySQL in a production environment.

While this may be taken as a troll by the MySQL fan base, it is a serious
critique from an experienced engineer.

MySQL does not support enough "SQL" to create efficient queries. You
end up doing a lot of post processing to reduce further your result set. The SQL
it does support is implemented fairly poorly. Sure, "SELECT * from mytable
where foo = bar" works well, but beyond that you have to post on community
sites to hear that certain equivalent elements and methodologies have horrible
pathological behaviors.

For instance:

SELECT * from hugetable where foo in (select bar from mytable)


The reason I am posting this is that as "open source" and "free
software" supporters, I wish we could reduce (as a community) our focus on
MySQL because it really isn't all that much about freedom, and focus more on
technologies like PostgreSQL or even SQLite. Because the former is better and
the latter is smaller, and both are very community centric and get far less
funding and attention.

[ Reply to This | # ]

Review of Russell Dyer's MySQL in a Nutshell, Second Edition
Authored by: Anonymous on Friday, September 26 2008 @ 04:26 PM EDT
A commercial on Groklaw?

Oh, well, thank you very much.

I will have to put it on my buy list.

It is an educational experience to read a reference manual from cover to cover.
A bit dry, but it is amazing what seems to stick.

[ Reply to This | # ]

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 )