Photograph by Marie A. DyerRussell J.T. Dyer, Writer
The works and musings of an american fiction and technical writer living in Milan, Italy • Updated: Oct 05, 2008 - 5:39PM • 8527 hits past day

Technical Books

For the last six years I have been working as a technical writer of open-source software, specializing in the database MySQL. I have published one technical book so far, a computer software manual on MySQL called, MySQL in a Nutshell (O'Reilly May 2005). In keeping with the publisher's Nutshell series, my book is written primarily in a reference or dictionary style with the syntax, explanations, and examples of MySQL statements, clauses, and functions. Additionally, the start of the book provides a basic MySQL tutorial along with instructions on installing MySQL. For application program interfaces (i.e., Perl, PHP, and C API) chapters, there are tutorials for getting started with each.

This first edition, written in English, has been translated into German, Japanese, and Polish so far. Click on the image for a particular language version to the left to read more about each. The links will take you to the publisher's web site. To read reviews of my book, click on the link in the margin for Nutshell Reviews. I've finished writing the second edition in December 2007 and we've finished the editing at the beginning of January 2008. The book is now in production and should be available at bookstores by the middle of April, in time for the MySQL Conference.

Comparison of Editions

As mentioned above, the second edition of my book, MySQL in a Nutshell is finished and in production. I've said elsewhere on this site as I've been working on it that the new edition is much better. Below is a comparison between the first edition and the second edition; I've provided first below an excerpt of the MySQL function MAX( ) from the 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;

This is simple and straight forward for a very basic function. While descriptions like this are sufficient, I pushed myself to elaborate more on MySQL statements and functions, as well as to find more realistic examples and alternative uses for them. Below is the explanation of the same function in the 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.

Here's an example of another handy, but less obvious use of this function: suppose we have a table in which client profiles are kept by the sales people. When a sales rep changes a client profile through a web interface, instead of updating the existing row, the program we wrote creates a new entry. We use this method to prevent sales people from inadvertently overwriting data and to keep previous client profiles in case someone wants to refer to them later. When the client profile is viewed through the web interface, we want only the latest profile to appear. Retrieving the latest row becomes bit cumbersome, but we can do this with MAX( ) and a subquery as follows:

SELECT client_name, profile, 
  MAX(entry_date) AS last_entry
FROM
   (SELECT client_id, entry_date, profile 
    FROM client_profiles
    ORDER BY client_id, entry_date DESC) AS profiles
JOIN clients USING(client_id)
GROUP BY client_id;

In the subquery, we retrieve a list of profiles with the date each has in its entry in the table client_profiles; the results contain the duplicate entries for clients. In the main query, using MAX( ), we get the maximum (latest) date for each client. The associated profile is included in the columns selected by the main query. We join the results of the subquery to the clients table to extract the client's name.

The subquery is necessary so that we get the latest date, instead of the oldest. The problem is that the GROUP BY clause orders the fields based on the given column. Without the subquery, the GROUP BY would use the value for the entry_date of the first row it finds, which will be the earliest date, not the latest. So we order the data in the subquery with the latest entry for each client first. GROUP BY then takes the first entry of the subquery results, which will be the latest entry.

Even if you don't know anything about MySQL and therefore don't understand the text above, I think you can see that the second edition is much better written and provides more assistance to the reader. You can see why I have been excited about the work I've been doing for the past year and why I'm eager for it to be published, why I'm so proud of it.

Reviews

Below are excerpts from reviews of MySQL in a Nutshell. Click on the heading of a review to see the full review. Please let me know if see one that's not included here.

Unix Review

There are many books on MySQL filling the bookshelves, but one that you must buy in order to have the necessary documentation for MySQL is MySQL in a Nutshell.
Emmett Dulaney
July 2005

Amazon.com

It is a very comprehensive text that reads as easily as a favorite novel yet is concise enough to be your first 'go-to' on MySQL issues you may face day-in and day-out.
Rob Wehrli
January 2006

Groklaw

All the commands are clearly laid out, with all the options and even useful examples! Lovely!
Steve McInerney
July 2005

Linux Format

Weve waited too long for a MySQL in a Nutshell book, and this book satisfies completely.
Paul Hudson
July 2005

WhiteMountain Perl Monger

MySQL In A Nutshell starts off with a (very) brief introduction (I like that too), plus a short installation guide and tutorial. Then it gets right into the meat of things with the SQL reference.
Andrew Brosnan
July 2005

Groklaw

If you program with/for MySQL databases, then I do recommend this book as an excellent reference guide into all things programmy about MySQL.
Steve McInerney
July 2005

Phoenix MySQL User Group

Dont let the size of the book fool you. The information it contains is well laid out into identifiable topics for easy reference.
Brett Berry
June 2005

LinuxQuestions.org

It's quick and to the point approach to me gives it a quick thumbs up as it doesn't go into too many details but outlines the basic processes with enough detail that even those that aren't familiar with MySQL installations could easily follow..
trickykid
May 2005

Blogcritics.org

With MySQL in a Nutshell, Dyer has provided the perfect desk reference for this powerful DB engine...
DrPat
May 2005

Amazon.com

I'm not a SQL expert, so I liked the tutorial-flavored introductions at the beginning of each chapter, followed by the conversational tone of the clear and concise examples.
Larry Hannay
May 2005

Amazon.com

Well the book certainly seems to cover MySQL's features quite comprehensively...For a given MySQL command, the book's explanation is succinct and useful.
Wes Boudville
May 2005