"Simply SQL"
by Rudy Limeback
Link: http://www.amazon.co.uk/Simply-SQL-SitePoint-Rudy-Limeback/dp/0980455251/
Reading history and reviews
Finished on 2nd February 2011
"Simply SQL" is an overview of SQL targeted at web application developers, with the intention of filling a gap between the basic "SQL 101"-type tutorials (seemingly compulsory in just about every introductory article or book about web programming) and texts covering more advanced topics which are perhaps not so directly relevant to the straightforward requirements of many web applications.
The book is divided into two groups of chapters: the first deals with the details of the SQL language and comprises the bulk of the book, while the second covers some basic database design concepts (specifically SQL data types, relational integrity, and the use of "special structures" for particular situations). The majority of the book focuses on the SELECT command, with only a short introduction to the other "usual suspects" (CREATE, ALTER, INSERT, UPDATE, DELETE and so on): each chapter covers one specific SELECT clause - FROM, WHERE, GROUP BY and so on - in extensive detail, and illustrated with examples from sample applications. The heavy emphasis on SELECT might seem odd, but it makes a lot of sense in the context of web applications where data is typically read from the database far more than it's written.
The clear and detailed explanations are a pleasure to read, and the examples are excellent for clarifying some of the slipperier concepts (I found them invaluable for understanding the subtleties of the GROUP BY and HAVING clauses, used for aggregating data from subsets of rows, which were completely new to me). I felt that I learned a lot of useful things, for example, the distinctions between the FLOAT and DECIMAL data types (DECIMALs are exact - within certain limits - while FLOATs are approximate), the concepts of views, derived tables and subqueries, and use of foreign keys for maintaining relational integrity.
It's important to note that "Simply SQL" is based on the SQL standard (although the author indicates where popular implementations such as MySQL deviate from it) and that it doesn't cover any of the programming APIs, so it's not really a reference text. However with its clear and detailed explanations it looks like it would be a useful companion to more traditional reference or cookbooks and will definitely reward re-reading. So overall highly recommended.