|
|||||||||||||||||||||||||||||||||||
|
56 Reviews
|
Average Customer Review
Share your thoughts with other customers
Create your own review
|
|
Most Helpful First | Newest First
|
|
43 of 43 people found the following review helpful:
5.0 out of 5 stars
Good tutorial on and selection of recipes solving problems with SQL,
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
Ultimately, the goal of this book is to give you a glimpse of what can be done using SQL outside of what is considered the typical SQL problem domain. This text is unique in that the target audience is wide, incorporating all levels of SQL programmers as well as those who are completely unfamiliar with SQL.
Both complex and simple solutions are provided, and solutions for five different vendors are available when a common solution does not exist. These five databases are DB2 v.8, Oracle Database 10g (with the exception of a handful of recipes, the solutions will work for Oracle8i Database and Oracle9i Database as well), PostgreSQL 8, SQL Server 2005 and MySQL 5. All of the examples are built around a small set of tables containing employee data. This helps the reader get familiar with the example data, so that, having become familiar with the data, you can focus on the technique that each recipe illustrates. Chapter 1, Retrieving Records, introduces very simple queries. Examples include how to use a WHERE clause to restrict rows from your result set, providing aliases for columns in your result set, using an inline view to reference aliased columns, using simple conditional logic, limiting the number of rows returned by a query, returning random records, and finding NULL values. Most of the examples are very simple, but some of them appear in later more complex recipes, so it's a good idea to read this chapter if you're relatively new to SQL or aren't familiar with any of the examples listed for this chapter. Chapter 2, Sorting Query Results, introduces recipes for sorting query results. The ORDER BY clause is introduced and is used to sort query results. Examples increase in complexity ranging from simple, single-column ordering, to ordering by substrings, to ordering based on conditional expressions. Chapter 3, Working with Multiple Tables, introduces recipes for combining data from multiple tables. If you are new to SQL or are a bit rusty on joins, this is a good chapter to read before going on to Chapter 5 and later. Joining tables is what SQL is all about; you must understand joins to be successful. Examples in this chapter include performing both inner and outer joins, identifying Cartesian productions, basic set operations (set difference, union, intersection), and the effects of joins on aggregate functions. Chapter 4, Inserting, Updating, Deleting, introduces recipes for inserting, updating, and deleting data, respectively. Most of the examples are very straightforward, perhaps even pedestrian. Nevertheless, operations such as inserting rows into one table from another table, the use of correlated subqueries in updates, an understanding of the effects of NULLs, and knowledge of new features such as multi-table inserts and the MERGE command are extremely useful for your toolbox. Chapter 5, Metadata Queries, introduces recipes for getting at your database metadata. It's often very useful to find the indexes, constraints, and tables in your schema. The simple recipes here allow you to gain information about your schema. Additionally, "dynamic" SQL examples are shown here as well, i.e., SQL generated by SQL. Chapter 6, Working with Strings, introduces recipes for manipulating strings. SQL is not known for its string parsing capabilities, but with a little creativity, usually involving Cartesian products, along with the vast array of vendor-specific functions, you can accomplish quite a bit. Some of the more interesting examples include counting the occurrences of a character in a string, creating delimited lists from table rows, converting delimited lists and strings into rows, and separating numeric and character data from a string of alphanumeric characters. Chapter 7, Working with Numbers, introduces recipes for common number crunching. You'll learn how easily window functions solve problems involving moving calculations and aggregations. Examples include creating running totals; finding mean, median, and mode; calculating percentiles; and accounting for NULL while performing aggregations. Chapter 8, Date Arithmetic, is the first of two chapters dealing with dates. Being able to perform simple date arithmetic is crucial to everyday tasks. Examples include determining the number of business days between two dates, calculating the difference between two dates in different units of time (day, month, year, etc.), and counting occurrences of days in a month. Chapter 9, Date Manipulation, is the second of the two chapters dealing with dates. In this chapter you will find recipes for some of the most common date operations you will encounter in a typical work day. Examples include returning all days in a year, finding leap years, finding first and last days of a month, creating a calendar, and filling in missing dates for a range of dates. Chapter 10, Working with Ranges, introduces recipes for identifying values in ranges, and for creating ranges of values. Examples include automatically generating a sequence of rows, filling in missing numeric values for a range of values, locating the beginning and end of a range of values, and locating consecutive values. Chapter 11, Advanced Searching, introduces recipes that are crucial for everyday development and yet sometimes slip through the cracks. These recipes are not any more difficult than others, yet many developers make very inefficient attempts at solving the problems these recipes solve. Examples from this chapter include finding knight values, paginating through a result set, skipping rows from a table, finding reciprocals, selecting the top n records, and ranking results. Chapter 12, Reporting and Warehousing, introduces queries typically used in warehousing or generating complex reports. Examples include converting rows into columns and vice versa (cross-tab reports), creating buckets or groups of data, creating histograms, calculating simple and complete subtotals, performing aggregations over a moving window of rows, and grouping rows based on given units of time. Chapter 13, Hierarchical Queries, introduces hierarchical recipes. Regardless of how your data is modeled, at some point you will be asked to format data such that it represents a tree or parent-child relationship. This chapter provides recipes accomplishing these tasks. Creating tree-structured result sets can be cumbersome with traditional SQL, so vendor-supplied functions are particularly useful in this chapter. Examples include expressing a parent-child relationship, traversing a hierarchy from root to leaf, and rolling up a hierarchy. Chapter 14, Odds 'n' Ends, is a collection of miscellaneous recipes that didn't fit into any other problem domain, but that nevertheless are interesting and useful. This chapter is different from the rest in that it focuses on vendor-specific solutions only. This is the only chapter of the book where each recipe highlights only one vendor. In some cases, though, you'll be able to easily tweak a solution provided in this chapter to work for a platform not covered in the recipe. Appendix A, Window Function Refresher, is a window function refresher along with a solid discussion of groups in SQL. Window functions are new to most, so it is appropriate that this appendix serves as a brief tutorial. Additionally, the use of GROUP BY in queries is a source of confusion for many developers. This chapter defines exactly what a SQL group is, and then proceeds to use various queries as proofs to validate that definition. The chapter then goes into the effects of NULLs on groups, aggregates, and partitions. Lastly, you'll find discussion on the more obscure and yet extremely powerful syntax of the window function's OVER clause (i.e., the "framing" or "windowing" clause). Appendix B, Rozenshtein Revisited, is a tribute to David Rozenshtein, author of "The Essence of SQL". Appendix B focuses on some of the queries presented in "The Essence of SQL", and provides alternative solutions using window functions (which weren't available when The Essence of SQL was written) for those queries. I highly recommend this book for anyone working with or interested in working with SQL. However, you should already be familiar with the theory behind database management or you will have trouble with this book.
55 of 57 people found the following review helpful:
4.0 out of 5 stars
Excellent book on SQL and the platforms recognized in this book!,
By
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
This book is just fantastic. One really needs to read the inside cover pages to see what this book doesn't try to do. The relevant elements are:
Non-political (on several SQL-specific fronts) Non-Pure ANSI (portability versus vendor-specific features) Non-platform (I couldn't find a mention of a particular platform) Basically, the book focuses on how to accomplish numerous SQL tasks using SQL and those features found on some of the top RDBMS vendors' products. It is selective in that the focus is constrained to MS SQL (platform obvious, but not mentioned that I could find) Server, DB2, MySQL, PostgresSQL and Oracle. I think that this well represents at least the 80/20 rule of who's running what RDBMS. The book is a set of recipes for (usually) each of these platforms. Each recipe is a code-demonstrated "how-to" for accomplishing the given task. This is perfect for those who don't want to become DBAs and focus on learning "too" much about SQL, rather, want to use an example in their code to make it do the right thing. The book is very well written and finished. It is a joy to read. The one detraction that I can think of is that it would be nice to see all of the examples online at O'Reilly's web site so that we could "play around with them" somewhat without having to enter the database table contents and all of the SQL by hand. It "ain't that hard," but who's got the time to do it? I think that having the code available with the book would make it an excellent training tool for newcomers to SQL and those switching to a different product such as going from Oracle or MS SQL to MySQL or PostgresSQL. However, as it is, the book is a 4.5 stars product. If you're interested solely in MySQL, check out the MySQL Cookbook from O'Reilly.
27 of 27 people found the following review helpful:
5.0 out of 5 stars
Mind-expanding,
By
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
It doesn't take long to learn the basics of SQL. Once you start to do multi-table joins and you get to sub-selects and outer joins you can almost convince yourself you are an expert. Trust me. You aren't. I've read at least ten books on using SQL. This is the first one to blow my horizons away and open a completely new landscape.
The "recipies" are well explained and almost entirely practical and useful. This book showed me dozens of things I did not ever think of using SQL for, even though I have the BNF for SQL pretty much in my head after more than 18 years of being a practicing programmer. Before this book I used to recommend "generic" SQL books to students and newbies because such books apply to virtually all SQL databases and it can be harmful for one to use a specific "dialect" (such as Oracle or SQL Server) that won't port to other SQL databases. I would urge people to learn "generic" SQL. You can always add the features of you specific dialect, but it is hard to give up features you assume will be in all dialects. This book neatly avoids that problem by providing dialect-specific sections when you can or must code differently for a particular database. Even better, they explain the differences and the pros and cons of those differences. So this book can even be an aid to selecting the "right" database for your application. I happen to be a fan of Open Source and Free Software and I'm pleased to say that this book covers both MySQL and PostgreSQL. Naturally it provides the "big three" of Oracle, Microsoft SQL Server, and IBM's DB2. This book really opened my eyes to possibilities in SQL that I really didn't know existed in spite of the fact that I have been using the language (apparently without mastering it) for almost two decades. I still recommend using a "generic SQL" book to learn the basics, but this should literally be ordered at the same time. It is the best of the "Cookbook" series that I have seen. (And I have used the Java Cookbook, Perl Cookbook, and Python Cookbook).
9 of 9 people found the following review helpful:
5.0 out of 5 stars
whoa! this is SQL?,
By Evan Galois (Chicago, IL) - See all my reviews
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
When you've been programming for quite sometime rarely
will any books surprise you. To my surprise molinaro offers solutions i haven't seen before. There is a heavy focus on "window functions" (which have been available to other vendors but are brand new to sql server so i was quite excited to see a deep treatment of that) along with use of vendor specific functionality which makes for elegant solutions. While there are things i typically would not do in sql, for example, building delimited lists from result sets or parsing strings, very clever and readabable solutions for both are provided. The window function "refresher" is a welcome chapter and the author provides a very nice treatment of GROUP BY (if you've ever had trouble with GROUP BY queries, you'll appreciate this chapter). Molinaro provides an interesting spin on what groups in SQL are. Having a background in sybase,access, and sql server, i appreciate the tribute chapter to David Rozenshtein. While Molinaro's solutions are very different, he acknowledges the traditional techniques and in some cases shows old and new, side by side. all in all, a great book, showing off new and interesting sql techniques.
8 of 8 people found the following review helpful:
5.0 out of 5 stars
a great second book on sql,
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
because the focus is on queries (the author states this on the cover and preface) you'll need a more traditional book on learning sql if you are completely new to it.
once you know the basics, this is a great "where to go next" book. there are chapters for complete novices, but being a "cookbook" (q&a format), i would not suggest this text as your only text on sql. instead this would make a good supplement to any of the intro sql books avaialable. This book does a nice job of showing when and how to use different constructs of sql. for example, once you learn GROUP BY (there is a window/group by tutorial in the back of the book), you might wonder when exactly do you use it or what queries do you use it for? the recipes in this book do a nice job of explaining how various sql constructs (aggregates, window functions, pivot queries, etc) work and when to use them by tying verbal descriptions to real queries. this is a good book for novice or intermediate developers looking to take their sql to the next level or dbas looking to improve their sql skills.
7 of 7 people found the following review helpful:
5.0 out of 5 stars
Excellent Recipes for both novice and expert programmers,
By CyberSimba (Boston, MA USA) - See all my reviews
Amazon Verified Purchase(What's this?)
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
I am really glad I bought this book. This book covers substantial amount of sql problems that you would practically come across.
-For each problem, the book illustrates the solution and the rationale behind it. It also discusses solution for different databases. -Each problem/solution is discussed for MySQL, Oracle, PostgreSQL, DB2 and SQL Server. -Best thing I like about the book is that it doesn't just discuss the solution but it also gives you enough details so that you understand the database specific behaviour. For e.g. 'rownum' concept in Oracle is very nicely explained with respect to the context. -I have been writing SQLs for years. Still I came across very valuable techniques and tricks that I had not heard or used before buying this book. -The explanation style used in this book is also very reader friendly. What I mean is a lot of technical books get very very technical and boring. I felt exactly the opposite while reading this book. If there is a concept that you should understand before book discusses it in details, this book makes sure that it is explained enough for you to dive into the details given later. I would highly recommend this book for anyone looking to have a reference SQL book that would help them get answers to common and advanced SQL problems in day to day SQL programming.
27 of 34 people found the following review helpful:
5.0 out of 5 stars
Fantastic resource for anyone using SQL,
By Jack D. Herrington "engineer and author" (Silicon Valley, CA) - See all my reviews (VINE VOICE) (REAL NAME)
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
This is a great book for anyone writing SQL. Get it right now.
Oh, you want a reason? Ok. The chapter on querying hierarchal data effeciently, which is the bane of all SQL programmers, is worth the money right there. Oh, yeah, and the other chapters are great too. Get it. Right now.
6 of 6 people found the following review helpful:
5.0 out of 5 stars
Hand's down GREAT!,
By
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
O'Reilly cookbooks are always a great way to quickly solve everyday problems...but this one goes above and beyond when it comes to solving sql problems! Within the first 5 minutes of flipping through the book I was able to get pure sql solutions to two of the more nagging problems I was using a lot of other code to accomplish (turning table rows into a delimited list, and parsing ip addresses in a field).
As a few other reviews have mentioned, it was really great to also have solutions for various DBs listed side-by-side. For consultants like me who are forced to work with a variety of databases, it makes my job A LOT easier knowing I can just turn to this book to get the syntax of a specific trick no matter if I'm working with Oracle, MySQL, SQL Server, PostgresSQL, or even SQL Light. If you have a need to interact with a database, this book will def. give you some tips and tricks to make your life easier AND most likely speed up the performance of your apps.
6 of 6 people found the following review helpful:
5.0 out of 5 stars
sql minimalism,
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
Of the many things i like about this book is that many times the queries accomplish so much with so little code. Two examples that immediately caught my eye are the join-less versions of computing medians and running totals. Those two operations typically involve self-joins and can be inneffiicent if the tables are large.
Though I haven't tried the proposed solutions, they look promising simply because joins are no longer necessary! I also thought the "walking a string" technique was very clever considering sql does not have loops. Besides the "new-style" sql, what real sets this book apart are three things: 1. 5 vendors shown side by side. this is the first text I've seen that shows solutions for oracle, sql server, db2, mysql, and postgresql side by side, and all in their native syntax. When i saw all the different vendors listed on the cover, I thought the author was going to mix and match(ie, show one vendor here, one vendor there). To my surprise, each solution shows all 5 versions when a single universal solution isn't available! 2. Longer queries are given longer explanations and shorter queries are given shorter ones. brilliant. 3. The intermediate steps are extremely helpful. when given more involved queries the author not only explains each portion of the query but shows their results. I find this particularly helpful as i dont have to try to visualize what each particular join or function-call does to the result set. The author takes complex sql, breaks it down to simple form, and builds it back up again to the final solution showing the intermediate result sets all the way. This makes the recipes easy to understand.
5 of 5 people found the following review helpful:
5.0 out of 5 stars
excellent explanations,
This review is from: SQL Cookbook (Cookbooks (O'Reilly)) (Paperback)
the chapter on reporting and warehousing queries is what made me decide to pick up this book.
the author's approach to explaining queries is great. the author takes his time explaining these queries step by step and showing what each construct of a query does. But what i found most useful for understanding is that the author also shows what the result sets would look like WITHOUT specific constructs. by doing this, you see exactly what these constructs mean to the final result set, why the author uses them, and what the query would look like without them. i find it easier to understand the big picture this way as the author explains WHY certain parts of the query are necessary and does so by showing what the results look like without them as well. a perfect example, the author spends 11 pages carefully explaining and breaking down single and multiple row pivots (also referred to as transpositions) by: 1. showing the steps to build these queries from scratch 2. showing what the result sets look like along the way 3. showing what changing specific aspects of the query means to the final result set and intermediate result sets alike. that's the key for me, not just explaining how changes effect the result set, but actually showing the intermediate result sets and how they change. bottom line: the author doesnt rush through the explanations and doesn't make you feel like you should already see what's going on. i find it much easier to grasp complex queries this way. |
|
Most Helpful First | Newest First
|
|
SQL Cookbook (Cookbooks (O'Reilly)) by Anthony Molinaro (Paperback - December 23, 2005)
$39.95 $24.32
In Stock | ||