Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×

SQL Cookbook 172

Simon P. Chappell writes "One of the staples of corporate I.S. development is processing data, and increasingly these days that data lives in a relational database. The lingua franca of relational database programming is the Structured Query Language (SQL), often pronounced "sequel". Many programmers find that the basics of SQL are easy to learn, but after that, it tends to get complicated. Enter the SQL Cookbook from O'Reilly." Read the rest of Simon's review.
SQL Cookbook
author Anthony Molinaro
pages 595 (9 page index)
publisher O'Reilly
rating 8/10
reviewer Simon P. Chappell
ISBN 0596009763
summary If you need help working with a database, this is the book for you.


The book is not for beginners and makes no efforts to teach any SQL. It concentrates purely on building on the base level of SQL knowledge that most programmers have. If you know the basics: Create, Read, Update and Delete (an unfortunate, yet memorable acronym) but rarely go beyond that, this book is for you. I know that I fall into this target market.

The point of the cookbook is that you need to get something done and you need to get it done sooner rather than later. Now, most of us can figure out most things given enough time, but in the real world, we rarely have enough time. The cookbooks objective is to save you time by giving you a successful approach that you could have figured out eventually anyway.

If you've previously read any other technology cookbook from O'Reilly, then you already know the structure of the recipes. For those new to the O'Reilly cookbook format, it's actually fairly straightforward. Each recipe starts out with a problem statement. Recipe one in chapter one, titled "Retrieving all Rows and Columns from a Table" has the problem statement "You have a table and want to see all of the data in it." Nice and clear. Then comes the solution. Naturally, for this problem statement we end up with a SELECT that looks like this:


select * from emp


Then the recipe has a discussion section where the solution is explained in more detail and the reasoning behind it is provided. For recipe one, the discussion explores the trade-offs between using the "*" to signify all columns versus naming each column explicitly.

The chapter structure through the book is very much one of building on the previous material. The first chapter starts with the fundamentals, the retrieving of records and then chapter two takes over with sorting the results of your query, while chapter three looks at using multiple tables.

Chapter four covers inserting, updating and deleting records. After that it's back into the world of queries, with chapter five exploring metadata queries for those times when you need to know just a little more about what's going on under the covers. Chapter six looks at working with Strings, a much harder topic than it would seem at first thought. Chapter seven addresses working with numbers and chapter eight does the same for date arithmetic with chapter nine bringing more understanding to general date manipulation. Chapter ten looks at working with ranges.

Chapter eleven dives into advanced searching in preparation for chapter twelve's information on reporting and (data) warehousing. Hierarchical queries are always challenging, so they're reserved for chapter thirteen. Finally, chapter fourteen is titled "Odds 'n' Ends" and is a general catch-all for some pretty advanced, but very infrequent problems.

I guess you either like the recipe approach or not. I love it, so I'm listing it as something to like about this book. The recipes are very well explained and while each one presents only one approach, where there are obviously multiple options, the discussion takes care to explain the reasoning behind the selection.

The writing is clear and the explanations are well laid out. Both the SQL code and the query results are presented well and are easy to read.

A very important part of the book is that it covers SQL variations for Oracle, IBM's DB2, Microsoft SQL Server and the open-source databases PostgresSQL and MySQL. Each of the recipes includes solutions for each of the five databases. While SQL is a standard, there seems to be some very relaxed definitions of full adherence to that standard; hence the book has to present up to five solutions for each problem.

Many of the recipes are advanced. While the front of the book has the entry level material, it ramps up in complexity pretty quickly. For some of us with very straightforward SQL knowledge, some of the recipes are going to take a while to fully understand and be able to use.

Many of the recipes are obviously oriented towards corporate reporting. If this is a big need for you, then this book goes along way to meeting your needs. If you have no need for corporate reporting, it's wasted paper.

This is an excellent book; it does exactly what it sets out to do and fully equips you to handle the most sophisticated database transactions.


You can purchase SQL Cookbook from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

SQL Cookbook

Comments Filter:
  • by east coast ( 590680 ) on Wednesday May 10, 2006 @03:23PM (#15303282)
    Indeed. I was always under the impression that "sequel" came from an old precursor to SQL called Structured English Query Language (Thus SEQL). Oh well, what do I know. I still call it S.Q.L. myself.
  • Re:Recommendation (Score:4, Interesting)

    by WindBourne ( 631190 ) on Wednesday May 10, 2006 @03:44PM (#15303463) Journal
    Normally, I do staight coding on servers, sometimes the client. Most of my work does not involve huge amounts of DB work. So I get by on the DB, but I do not consider it a strength.

    Now, I am in a job where currently, I am testing data that is being modified through a series of transforms. We test by loading the end work and taking it back to the initial work (i.e. we reverse the process). We find it easy to load the data into a Postgres DB, create views with conversion functions to take end->initial and then run an assortment of queries over the data to make certain that it is correct. I have found that I do go back to several book to make sure of my sql as well as to improve the speeds (a subquery took 20 min to run while using a except gaves a similar answer in under several seconds. BIG difference considering that we are looking at many tables with a number of tests each).

    The books help.
  • Re:Mispronunciation (Score:1, Interesting)

    by Anonymous Coward on Wednesday May 10, 2006 @03:53PM (#15303533)
    Chris Date has stated in many of his books on RDMS theory and practice, several of which were published before many Slashdotters were born, that SQL is pronounced 'sequel'. Good enough for me.
  • Re:Recommendation (Score:3, Interesting)

    by rainman_bc ( 735332 ) on Wednesday May 10, 2006 @05:27PM (#15304272)
    Now, I would like to have this book to support my own ends, but as a report guy, I don't particularly need it. Why not? Because Crystal does it for me. Anything so complicated that Crystal will screw it up

    I'm a report guy, and let me tell you that you cannot count on Crystal to do it all for you. Sometimes the request comes in is too complex to solve without using correlated subqueries, derived tables, and the like which Crystal Won't properly use for you.

    Trust me, I work for an online gaming company, and some of the requests can get amazinhgly obscure.

Anyone can make an omelet with eggs. The trick is to make one with none.

Working...