Errata

The Art of SQL

Errata for The Art of SQL

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 3
3rd bullet point from bottom

"Fuel, consumption, tank capacity" s.b. "Fuel consumption, tank capacity" (i.e., eliminate first comma)

Anonymous  Feb 24, 2012 
Printed Page 3
3rd bullet point from bottom

Please disregard my prior submission; the printed text is correct as written!

Anonymous  Feb 25, 2012 
Printed Page 19-20
too many paragraphs have errors to list them all here

Print History: March 2006 printing

The discussion starts off by asking the question, "Instead of storing the effective date from which the price applies, why not store the "end date" (e.g. the last date on which the current price prevails), identifying the time intervals by their upper bound or by their lower bound?"

This question is awkwardly structured, long and convoluted. It seems the author is suggesting we overhaul the example from the previous page, where the table is (article_id, effective_from_date, price). In other words, it seems the author is suggesting that "Instead of" the previous table, we use the following table: (article_id, end_date, price).

However, the final clause in this question introduces unnecessary convolutions. No matter what scheme we use, we need to identify time intervals by their upper bound AND (not "or") by their lower bound; that is the definition of a time interval. The real question the author wants to ask the reader, it seems, is whether an explicit end_date field and implicit effective_from_date field is superior to an explicit effective_from_date field and implicit end_date field.

To make matters more confusing: In the code example on the page, the author ends up not using an end_date field at all. Instead, the author copies and pastes the query from Page 19, and adds one extra predicate to the where clause. However, paragraph 5 on page 20 DOES mention an end_date field explicitly, and the formatting as well as underscores indicate it is a column name.

Furthermore, it is not clear the author's example code does what the text alleges. In fact, based on the line of questioning, it's incorrect, because the column name effective_from_date is being used. An end_date column name should be used.

Additionally, the query on page 19 is wrong, too. The effective_from_date column does not guarantee it is possible to have more than one effective_from_date greater than the sysdate. Without this uniqueness constraint on the column, the results of this query will vary due to run-time changes to the table that will not be guarded by the DBMS. Therefore, the query suggested on page 19 is not guaranteed to return the correct price for the author's question: "How are we going to identify the current value?"

Finally, the last paragraph on Page 20 misuses the word "denormalization"! The author suggests storing both effective_from_date and end_date is denormalization, but it is not. For instance, what happens if there is a period of time when the product was not sold? This is actually an important piece of information when data mining. Moreover, denormalization in the technically correct sense is not even a sensible option. What the DBA more than likely want to do in the scenario the author posed is use "precomputing" instead, caching the "current price" from the weak entity and storing it in the strong entity. This also eliminates a join every time somebody wants to know the current price, it eliminates the need for nested queries. However, this does not remove the requirement to store historical data and strategies for fast queries of time periods.

In my humble opinion, what the author should really be discussing is how to define a uniqueness constraint over a range of records in the table. However, the author does not do that, and ends up teaching the wrong approach pedagogically, misleading the reader with the wrong train of thought.

Overall, this is really confusing and I'm surprised it has not been reported as errata yet. This is a huge mistake that basically blots out the technical merit of the discussion in an important section of the book.

Anonymous  Aug 19, 2008 
Printed Page 158
Top lines of the page (Result Set Obtained by Aggregation, just above Simple or Range Searching on Dates)

However, this use of having does not really make sense if amount is always a positive
quantity or zero. In that event, we might be better using the following condition:
where amount > 0

As far as I know, it is also possible to acknowledge negative values. There may only be a problem when the sum of all values adds up to be exactly 0 again, but only when using aggregates. Since we do not need to use aggregates, we can simply select any record with an amount not equal to 0 to find out "if there are any" and to retrieve the customer_id.

So this clearly is an(other) advantage of not using aggregates: it also works for possible negative values combined with positive.

Can you think of a way to achieve this by using aggregates?
(Why would you want to anyway?)
Yes, by first taking the absolute value of any amount and then summing them all up... But why do it the difficult way?

Anonymous   
Printed Page 166
The rewritten query

The where clause of the rewritten SQL query is missing the condition "and type_code = 4" that was in the original query.

Anonymous   
Printed Page 202
the whole abstract layers - page 202 thru 205

The sample code which is being analyzed line by line under the abstract layer is wrong.

This code will be running LOCALLY, there is NO server access in this code.

In another word, at line 13 of the sample, dt.Select(expression) will be using the C# SQL engine to process. (like the sqlite, being mentioned in page 77, but with limit number of SQL functionality)

However as a DB and Application developer, I have to say the money I paid to buy this book is my best investment on my career.

Anonymous  Aug 18, 2008