Stories
Slash Boxes
Comments

News for nerds, stuff that matters

The Art of SQL

Posted by samzenpus on Wed Jun 07, 2006 02:22 PM
from the learn-all-about-it dept.
Graeme Williams writes "One difference between SQL and a conventional procedural programming language is that for SQL there's a bigger gap between what the code says and what the code does. The Art of SQL is the opposite of a cookbook – or rather it's about cooking rather than recipes. It's not a reference manual, although there's plenty to refer back to. It's an intermediate level book which assumes you know how to read and write SQL, and analyzes what SQL does and how it does it." Read on for Graeme's review.
The Art of SQL
author Stéphane Faroult with Peter Robson
pages xvi + 349
publisher O'Reilly Media
rating 9
reviewer Graeme Williams
ISBN 0-596-00894-5
summary An excellent way to improve your approach to SQL


I guess it's normal for an intermediate text to present a number of serious examples, the idea being that the code from an example can be applied to roughly similar problems with roughly similar solutions. I think Faroult's goal is both more abstract and more ambitious. He wants to expand your ability to navigate among and analyze alternative SQL statements with more confidence and over a larger range. This isn't so much a book about SQL as it is about thinking about SQL.

There's almost no chance that the SQL examples in the book will be directly applied to a real problem. The examples are relevant at one remove: What does thinking about this example tell me about thinking about my current problem? So the book doesn't come with downloadable samples. There's no point.

The first few chapters of the book lay a foundation for the rest. As each brick in this foundation is placed, it sometimes feels as though it's placed firmly on your head. Think about indexes ... whack! Think about join conditions ... whack! These chapters have very few examples – the goal is to force you to think through queries from first principles. It's more effective (and less painful) than it sounds.

These introductory chapters cover how a query is constructed and executed, including how a query optimizer uses the information which is available to it. Faroult discusses the costs and benefits of indexes, and the interaction of physical layout with indexes, grouping, row ordering and partitioning. He also explains the difference between a purely relational query and one with non-relational parts, and how such a query can be analyzed in layers. Chapter 4 is available on the book's web page. It will give you a good idea of the style of the book, but not of the level of SQL discussed – the longest example in the chapter is just 15 lines.

Chapter 6 presents and analyzes nine SQL patterns, from small result sets taken from a few tables, to large result sets taken from many tables. The chapter falls roughly in the middle of the book, and feels like its heart. Prior chapters have built up to this one, and subsequent chapters are elaborations on particular topics. The theme of the book, to the extent that it has one, is that details matter. Different SQL statements can be used to produce the same result, but their performance will be different depending on details of the data and database. A change to the database structure, such as adding an index, might improve performance in one set of circumstances, but make it worse in another. The case analysis in this chapter will make you more sensitive to details in query design and execution.

The authors almost never mention particular database products. Their justification is that any absolute statement would be invalidated by the next release, or even a different hardware configuration, and anyway, that's not the business they're in. But sometimes this can go too far. The phrase "A clever optimizer ... will be able to" is too hypothetical by half. Is this an existing hypothetical query optimizer, or a vision of a future optimizer? Or the optimizer of one hypothetical database product and not of another? I suspect that Faroult knows and is simply being coy. It's just unhelpful not to tell us what existing databases will do, even if depends on the release or the hardware.

Faroult does this because he's not much interested in telling you what actually happens when a particular SQL statement is executed by a particular database. If the authors wanted a cute title for the book, I'm surprised they passed over The Zen of SQL Maintenance. When you look at an SQL statement, Faroult wants you to see what other SQL statements would do under other circumstances. He literally wants you to see the possibilities.

The second half of the book continues the analysis of chapter 6 into special cases, such as OLAP and large volumes of data, monitoring and resolving performance issues, and debugging problematic SQL.

Chapter 7 discusses tree-structured data, like an employee table with a column for the employee's manager. Faroult likes his own solution best, but presents an alternative approach by Joe Celko clearly enough for you to explore that as well.

Chapter 8 includes a series of examples of SQL and PHP. For anyone like me who spends more time in various programming languages than in SQL, this chapter is a small gem. It nicely illuminates the care needed in deciding what happens in code and what happens in SQL.

Chapter 9 addresses locking and concurrency, as it applies to both physical and logical parallelism. Transactions are included, but the discussion is just one part of a 20-page chapter and seems thin.

The Art of SQL is very clearly written. Whether it is "easy" will depend on how comfortable you are with SQL. This book is targeted at (page xi) "developers with significant (one year or, preferably, more) experience of development with an SQL database", their managers and software architects. I have months of experience spread over a decade or more, so I'm nominally outside the target audience. I found the SQL examples and discussion clear once I had a chance to let them sink in. If you're working with SQL regularly, they'll be perfectly clear.

The graphs let down the otherwise high quality of the book. For example, Figure 5-3 shows a rate (higher is better) but the legend says "Relative cost" (higher is worse). Figures 9-1 through 9-3 on facing pages 228 and 229 show response time histograms for three different query rates but don't show what the rates are. The x-axis of Figure 10-1 seems to be calendar time, but it's decorated with a stop watch icon. And as a representative of rapidly aging boomers with rapidly deteriorating eyesight, could I beg book designers not to put figure legends in a smaller font than the text of the book? Diagrams should be simple and clear, not something to puzzle over.

This is a book to conjure with, but it's not a book for everyone. Some people may find it too abstract, with too much discussion of too few examples. If you're completely new to SQL, the book will be hard going. If you have very many years of experience with SQL, it's just possible that you won't find anything new in the book, although I expect you'll find a lot to think about. For anyone in between, The Art of SQL is a excellent way to improve the way you attack problems in database and query design.


You can purchase The Art of SQL 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.
Display Options Threshold:
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • BN vs Amazon (Score:3, Informative)

    by beavis88 (25983) on Wednesday June 07 2006, @02:32PM (#15489546)
    I know Amazon has software patents and all, but this (and just about every other book I see reviewed here) is ~20% cheaper at Amazon than it is at BN...
  • art (Score:4, Insightful)

    by Lord Ender (156273) on Wednesday June 07 2006, @02:35PM (#15489570)
    (http://127.31.33.7/)
    If you think SQL is an "art," you are a hack. Designing proper databases and the SQL to use them optimally falls under the domain of science/engineering. 95% of developers see relational databases simply as a means for a persistent data store, but that's not what it was designed to do. If you don't know engineering (what you do when designing functional systems*) from art (painting pictures, etc) you should have gone to a better college.

    See this page [wikipedia.org] for a start on the science of databases.

    *Yes, I know creativity is usually involved when designing things. That doesn't make it art.
  • Great Statement (Score:3, Funny)

    by lbmouse (473316) on Wednesday June 07 2006, @02:39PM (#15489587)
    (http://www.videosift.com/story.php?id=1780)
    "for SQL there's a bigger gap between what the code says and what the code does"

    I couldn't agree more. Sometimes while working in SQL I really wish I had a time machine [wikipedia.org] and a rubber hose.
  • Bummer, trees (Score:4, Insightful)

    by plopez (54068) on Wednesday June 07 2006, @02:39PM (#15489595)
    Chapter 7 discusses tree-structured data

    Looks like no discussion of many-to-many relationships. This would make any book on databases and sql queries of limited value, not much more than a beginner book.

    Trees are of limited value, they only exist in special circumstances. If you stick to tree structured data relations then you will almost always have to do wierd hacks that may threaten data integrity.

    While many-to-many *seems* harder, as a data model M:M is often a much better practicle solution. As well as modeling the reality of the situation in a much more accurrate manner.

    My $.02
  • by Osty (16825) on Wednesday June 07 2006, @02:44PM (#15489635)
    (http://www.daishar.com/blog)

    Perhaps that's what's wrong with database development these days (just check out The Daily WTF [thedailywtf.com], as it seems they have a SQL example every other day). When a single year of experience is considered "significant" and "experienced", it's no wonder there are so many crap DBAs out there. We look for people with 5+ years of C# experience (ha! Good luck finding someone with more than 5 years experience ...) for intermediate-level developer positions. There's no way someone with only a year of SQL experience would qualify for an intermediate-level DBA position.

    Just as background, I've been doing development on SQL Server for 6 years now (from SQL 7 to SQL 2005). I'm still learning, still finding ways to improve my code's cleanliness and performance, still finding new things I can do in SQL. For example, SQL 2005 finally has CTEs, making it only the second database to implement that ANSI SQL99 standard. CTEs make it very easy to do things that were painfully hard before, like walking a tree or implementing a recursive algorithm over sets of data.

    After my fourth year of working with SQL, I'd have been willing to say I had "significant" experience with SQL. Four years is arbitrary -- it really depends on how much you work with it day to day. Someone may have "significant" experience after only two years, while someone else may not be significantly experienced until he's worked with SQL for eight years. If you had to put a number of years on what would constitute significant experience, I'd err on the safe side and go with three or four years. Certainly not just one year.

  • Developers and SQL (Score:5, Insightful)

    As a DBA, if developers would read... oh.... I dunno... just Chapter 1... the basics of SQL... of this book... any SQL book really AND understand "the basics"... My job would be 100 times easier!

    I spend much of my time explaining why a 5 page SQL statement "that takes a long time" is NOT A DATABASE PROBLEM!
    /rant

  • A useful review - Thanks! (Score:2, Informative)

    by Anonymous Coward on Wednesday June 07 2006, @02:50PM (#15489675)
    Many so-called book reviews on Slashdot fail to review the book. Instead, they simply state what each chapter covers. This review is actually useful. It describes the book's target audience, gives a sense of what the book does and doesn't contain, and helps me understand whether the book would be useful to me. Thanks!
  • SQL says what to do (Score:5, Insightful)

    there's a bigger gap between what the code says and what the code does

    That's stated incorrectly. With SQL, the code says what to do, but it does not say how to do it. That's the difference between "normal" procedural code and languages like SQL.
  • SQL Books (Score:3, Insightful)

    by Municipa (99320) on Wednesday June 07 2006, @02:56PM (#15489707)
    Pretty much every book on SQL I've seen only gives you obvious examples and covers the most simple uses. Every project I've worked on (for about 10 years) where there is pre-existing SQL written, almost all of it is written inefficiently. I'm not sure this book explains this kind of thing. But I've found 99%+ of the time you don't need to use a cursor, and it's almost always slower.

    SQL can do a lot more than most programmers ever try to do with it. There are a lot of clever tricks you can use exploiting its set based nature. The only place I've seen clever solutions beyond simple insert/delete/update statements is some of the trade magazines; the one for MS SQL Server sometimes has some very neat examples. These trade magazines have examples and ideas presented using the SQL language of a particular database, but it's almost always portable wihtout much work. I consider myself pretty good at SQL and even I find it's hard to learn more to get to the point where I can design clever SQL more frequently. Anyone else find that too?

    Another thing I've noticed is on some open source projects (and perhaps some closed source ones), particularly web based ones, there is displayed at the bottom the number of database queries used to generate the page. They are often 10 or more, which almost always seems ridiculous. I think there just aren't all that many people out there who understands what SQL can do, how it's different than procedural languages and how to use it beyond a simplistic straight forward approach. Hopefully this book helps explain that - I'll probably browse a bit the next time I'm in a book store.
    • 1 reply beneath your current threshold.
  • Opening line (Score:2)

    by skiflyer (716312) on Wednesday June 07 2006, @02:56PM (#15489709)
    One difference between SQL and a conventional procedural programming language is that for SQL there's a bigger gap between what the code says and what the code does.

    What? My SQL code tends to do exactly what the code says it will, are you trying to say that it's a high level language or am I missing something here?
  • ... trying to read the sample chapter screws up the tab holding that page in firefox (1.5.0.4) - scrolling no longer works for that tab until you either close it or go to another url, etc. It's too bad, it sounds like a good read.
  • This is an excellent book (Score:3, Informative)

    I'm slowly working my way through it; it's a great book on a number of levels. The writing itself is very nice, with a real personality showing through and not just the usual dry technical flavor. The illustrations are done in a nifty "drawing" style that looks good and portrays the data well. The technical insights are very helpful; after reading what I've moved through so far I've rewritten some of my Rails code [blogs.com] to be more efficient.

    I highly recommend this book; the $40 you'll spend on it will be repaid the first time you delete a swath of Java looping code and replace it with an additional subquery. If I can do half as well on my next book [generating...javacc.com] I'll consider it a job well done.
  • sql vs. procedural (Score:2, Interesting)

    by JCOTTON (775912) on Wednesday June 07 2006, @03:12PM (#15489816)
    (http://www.geocities.com/josephbcotton | Last Journal: Tuesday January 10 2006, @09:27PM)
    Now that the subject has been raised, my 2 cents.
    I have found (and who can disagree (just trolling)) that at least half of the production databases that I have come across hare not normalized. Go figgure.

    Anyway, this being the case, I have found that SQL is poor in handling a non-normalized table/database. (cant really call a non-normalized table as a database can we? (nuther troll))

    For example. We keep a complete record for each person for each pay period. Even inactives.

    I am asked to give a list of all active employees for a date range, and a lot of payroll detail, personal detail, etc. Guess what? Simple SQL gives a lot of duplicate names. I wish that there was a simple way filter. (Yes, I can do this in sql, but my point is that it is not handled natively in sql. I would like a simple command - give me all names and all their data for the latest pay period - something like that.

    All procedural languages will handle this problem nicely.

    metaphors be with you

    • select distinct by mveloso (Score:2) Wednesday June 07 2006, @04:14PM
    • Re:sql vs. procedural (Score:4, Interesting)

      by cruachan (113813) on Wednesday June 07 2006, @04:22PM (#15490338)
      Firstly most production databases contain some denormalization. Indeed the art of designing a real database is knowing where and when to denormalize data. How much denormalization is required is dependent upon the database, access paths and application usage and is rarely more than a few fields or a table or two. Nevertheless real production databases that have been correctly denormalized often run orders of magnitude faster than those that rigidly stick to 3rd normalization throughout.

      Secondly what you are asking for is generally straightforward in any real dialect of SQL. Select distinct works fine, as do various scenarios with subselects and group by / having clauses (having is the most overlooked of the standard SQL clauses and it's use generally signifies you are using code written by someone who knows what they are doing).

      However if you have a good dbms to hand that implements user defined functions then usually the best way if to create a function that returns the uid of the record from the multiple recordset you require (i.e. last payroll record for employee x) and use that in the where clause.

      OTOH if you are stuck with MySQL then the first step you have to take is upgrade to Postgres :-)
      [ Parent ]
    • 2 replies beneath your current threshold.
  • by roblambert (230731) on Wednesday June 07 2006, @03:16PM (#15489867)
    (http://www.zabada.com/)
    You can get "Art of SQL" cheapest at Buy.com, see:


    Lowest Prices for 'Art of SQL'
  • an art? (Score:1)

    by SekShunAte (978632) on Wednesday June 07 2006, @03:17PM (#15489876)
    hmmmm...let's test that:

    SELECT Creativity.Passion, Creativity.Insightfulness, Ability.Palette, Ability.Colorscheme FROM Creativity INNER JOIN Ability ON Creativity.AbilityID = Ability.AbilityID WHERE Creativity.Passion = "Mediocre";

    Result Set:
    Creativity.Passion | Creativity.Insightfulness | Ability.Palette | Ability.Colorscheme
    Mediocre | Dreamer | Basic | Shit Brown

    I have way too much time on my hands.
  • procedural programming (Score:4, Insightful)

    by jbgreer (4245) on Wednesday June 07 2006, @03:23PM (#15489925)
    (Last Journal: Friday January 26 2007, @04:42PM)
    "One difference between SQL and a conventional procedural programming language is that for SQL there's a bigger gap between what the code says and what the code does."

    Well, certainly one difference between SQL and a conventional procedural programming language is that SQL isn't procedural, it's declarative. One describes the data a query such produce, rather than state a set of steps necessary to achieve a desired result.

    jbgreer
  • Sun Tzu! (Score:2)

    by fm6 (162816) on Wednesday June 07 2006, @03:27PM (#15489952)
    (http://picknit.com/ | Last Journal: Saturday July 29 2006, @03:58PM)
    The reviewer managed to miss something that's pretty important: the authors are totally infatuated with Sun Tzu's The Art of War, even to the point of copying that book's chapter titles [wikipedia.org]. Which is evidence either that they're educated people building on age-old wisdom — or they're half-educated dweebs copying a book that's faddish right now.
    • Re:Sun Tzu! by kpharmer (Score:2) Wednesday June 07 2006, @05:49PM
      • Re:Sun Tzu! by fm6 (Score:2) Wednesday June 07 2006, @07:40PM
    • Re:Sun Tzu! by lfourrier (Score:2) Thursday June 08 2006, @02:19PM
  • Difference (Score:2)

    by Brownstar (139242) on Wednesday June 07 2006, @03:31PM (#15489978)
    One difference between SQL and a conventional procedural programming language is that for SQL there's a bigger gap between what the code says and what the code does

    Or more importantly SQL is not a procedural programming language at all. Please don't try to compare the two together at all, it just leads to misconceptions about what SQL is and how it works.
  • the sample chapter is promising (Score:3, Informative)

    by sqlgeek (168433) on Wednesday June 07 2006, @03:31PM (#15489979)
    I like the look of this book quite a bit, judging soley from the sample chapter. It talks in a straight-forward manner about the factors that determine how a database goes about it's job and how you can make that job easier or harder. If the rest of the book plays out similarly then thorough understanding of this book as well as Tom Kyte's would make for a programmer I'd love to hire.
  • I have to recommend a good under $20.us book to go with it.

    http://www.powells.com/biblio?isbn=0071359532 [powells.com]
  • The food reference, I'll bite (Score:2, Interesting)

    by cerelib (903469) on Wednesday June 07 2006, @04:30PM (#15490381)
    If you are going to go with the cooking/food reference then I do not think SQL is like cooking. SQL is like ordering at a restuarant, where the restuarant is your DBMS. It's like programming in prolog. You don't tell prolog what to do; you tell it what you want. Just a thought.
  • There's a bigger CRAP (Score:2, Insightful)

    by dbdweeb (598548) on Wednesday June 07 2006, @04:56PM (#15490577)

    Regarding > "there's a bigger gap between what the code says and what the code does." I think that's a typo. It should read...

    there's bigger CRAP between what the code says and what the code does.

    There's a lot of code in the RDBMS and normally you shouldn't have to delve into the RDBMS' source... But you should know what it does and how to use it.

    I was once on a project where a DUHveloper needed to perform an unnatural sort on a key column. He needed to display the query results where certain rows always needed to be sorted to the end of the result set but there were no column values to meet the criteria. He had this HUGE amount of nested if statements that he had been working on for days. After I inquired as to what he was wasting all of his time on I showed him how to create a sort non-displayed column where you derive a value based on a CASE statement. I accomplished in 5 minutes what he had struggled for days on just because he didn't really know much about SQL.

    I've corresponed with Mr. Faroult on several occasions, I've used many of his scripts, and I've received a lot of email help from him... So based on my experience I'm betting his book is pretty good.

  • by Pentomino (129125) on Wednesday June 07 2006, @07:45PM (#15491433)
    (http://www.io.com/~nickb/ | Last Journal: Thursday February 15 2007, @12:56PM)
    So it's like Alton Brown's "I'm Just Here for the Data"?
  • by lateralus_1024 (583730) <mattbaha@@@gmail...com> on Thursday June 08 2006, @03:30AM (#15493073)
    ...The Art of SQL Injection. tough choice.
  • by GmAz (916505) on Wednesday June 07 2006, @02:39PM (#15489589)
    (Last Journal: Monday May 08 2006, @10:06AM)
    Ya, its off topic, but you are right. This new slashdot is nice and all, but stuff needs to go where it belongs.
    [ Parent ]
  • by mobby_6kl (668092) on Wednesday June 07 2006, @02:39PM (#15489597)
    I can't mod you up because I don't have any mod points, but I agree that I preferred the old one.

    To keep this at least somewhat on topic, the table with the book information seems to have 0 margins/padding [imageshack.us], making it a little ugly/difficult to read.
    [ Parent ]
    • 1 reply beneath your current threshold.
  • Re:Useless to all but theoraticians (Score:5, Insightful)

    by stoolpigeon (454276) * <bittercode@gmail> on Wednesday June 07 2006, @02:53PM (#15489690)
    (http://thepeckfamily.us/ | Last Journal: Monday November 12, @10:13AM)
    There are differences on the different platforms, but there is a standard and standard syntax ought to work in any rdbms. When it doesn't (access is the first example that comes to mind) that is a sign that what you are working with is not as good a system as it should be. One of the things I really like about postgres is that it is very standards compliant.
     
    There is a transact sql book that I use frequently on multiple database systems. A small amount doesn't carry over, due to syntax differences. But the ideas on how to deal with sets of information in sql carry over. It appears that this book does that intentionally. And it should be useful in a very practical way if it is at all like the description.
    [ Parent ]
  • by PCM2 (4486) on Wednesday June 07 2006, @02:58PM (#15489715)
    (http://neilmcallister.com/)
    It's great to see a book that tells me SQL can do pretty much anything - but I pretty much already knew that. This book might be good for THEORY, but for actually getting useful and applicable information, the review leaves me wondering who would be a worthwhile reader.

    And yet, if you get out and talk to some of the real-world database consultants who get called in to clean up other people's messes, one of the complaints you hear again and again is that too many so-called DBAs learned their trade on a specific product, rather than understanding why databases work the way they do.

    Optimizations that you introduce into your applications to cater to specific products' features (or work around their shortcomings) may be a fact of life, but they make for poor design choices. You should know what you're doing first -- which means a good understanding of database theory -- and layer all that syntactic hot-rod stuff on later.

    [ Parent ]
  • Re:Useless to all but theoraticians (Score:5, Insightful)

    by kfg (145172) on Wednesday June 07 2006, @02:59PM (#15489721)
    . . .the review leaves me wondering who would be a worthwhile reader.

    Software engineers and Database Administrators.

    An intuitive "hackers" understanding of physics is perfectly sufficient to construct a gocart out of 2x4s and baby coach wheels, but automotive engineers find that a knowledge of "theory" is rather useful in getting practical work done.

    In fact if your software does not have a solid grounding in theory it may well be worse than useless, as software is nothing more than applied science. The computer is a mathematics engine. Nothing less, nothing more.

    If you do not understand the underlying structure of your high level language and the low level mathmatical theory below that you liable to make grevious mistakes in first selecting your high level tools, then in the specific models that you impliment with your code and then in your code itself.

    And be utterly clueless that you have done so.

    KFG
    [ Parent ]
  • Re:SELECT * FROM first_post; (Score:5, Funny)

    by Anonymous Coward on Wednesday June 07 2006, @03:00PM (#15489727)
    +---------+
    | You     |
    +---------+
    | Fail It |
    +---------+
    1 row in set (0.08 sec)
    [ Parent ]
  • Re:Where's the news? (Score:4, Informative)

    by PCM2 (4486) on Wednesday June 07 2006, @03:04PM (#15489759)
    (http://neilmcallister.com/)
    Could Slashdot not post book reviews to the main section??

    I like book reviews.

    Homepage preferences [slashdot.org] are your friends.

    [ Parent ]
  • Theory not a dirty word (Score:5, Insightful)

    by fm6 (162816) on Wednesday June 07 2006, @03:13PM (#15489838)
    (http://picknit.com/ | Last Journal: Saturday July 29 2006, @03:58PM)
    This book might be good for THEORY, but for actually getting useful and applicable information, the review leaves me wondering who would be a worthwhile reader.
    SQL theory is useful and applicable. It's just not complete: you also need the specifics of whatever SQL implementation you're using. For that you need to go to books about the specific RDBMS you're using. You can't expect a general SQL book to cover every implementation of the language, any more than you expect Stroustrop [att.com] to tell you how to work with Visual C++.

    Not every programmer needs to be a computer scientist, but they do need to learn a little theory now and then. That's especially true when you're work with relational databases, which are full of weird abstractions and subtle performance issues. Not having looked at this particular book, I can't say whether its overkill for what most SQL people do. I can say that most database hackers don't seem to know as much theory as they should.

    [ Parent ]
  • by ZeroExistenZ (721849) on Wednesday June 07 2006, @03:14PM (#15489844)
    Wouldn't that rather be "SELECT TOP 1 FROM Posts WHERE sid=#06/06/07/194246#" ?
    [ Parent ]
  • Re:So According to the blurb... (Score:2, Informative)

    by Anonymous Coward on Wednesday June 07 2006, @03:21PM (#15489902)
    umm... dude? SQL has been around since the mid 50's. A guy at IBM developed it. Now, it was made before high level languages, and brother, that's why SQL is anchronistic and irreperably flawed.

    Yep, i said it.
    [ Parent ]
  • by mcmonkey (96054) on Wednesday June 07 2006, @03:21PM (#15489910)
    (http://www.evolt.org/)
    This book might be good for THEORY, but for actually getting useful and applicable information, the review leaves me wondering who would be a worthwhile reader.

    I guess you skipped all the threads about computer science vs. programming and uni degrees vs a tech certificate.

    Specifically regarding 'the best way to do x,' that may depend to a certain extent on the specifics of the platform at hand, but why do x? What do you hope to achieve? What are the desired results? Why not do y? If your thinking hasn't progressed past "basic syntax" you're not a hacker, you're a button pusher. Bang on your keyboard, you might as well be pounding rocks into gravel.

    This book might be good for THEORY, but for actually getting useful and applicable information...

    What do you think "useful and applicable information" is?? Think about driving a car. (*ducks* Yeah, the car analogies are played out.) The specifics of each make and model--the dashboard layouts, placement of controls--are your "basic syntax." These details are not the things you really need to know in order to learn how to drive. The THEORY of driving--concepts of acceleration, braking, steering--are the things you need to know BEFORE you can make proper use of the "basic syntax."

    The reader for whom this book would be a worthwhile read is the person with an understanding that theory IS useful and applicable information.

    [ Parent ]
  • WTF is a "theoraticians" (Score:3, Interesting)

    by mcmonkey (96054) on Wednesday June 07 2006, @03:39PM (#15490029)
    (http://www.evolt.org/)
    And who modded that comment Insightful? Come on folks, it's garbage.
    Point is nothing is really transferable
    So they seasoned pro with 15-years relational database experience who hasn't worked with new SQL-X is just as good as someone with no db experience on any platform? And when SQL-X 2.0 comes out, all those so-called experts, with their knowledge of SQL-X 1.9 are going to be useless, right? After all, "nothing is really transferable."

    EVERYTHING is transferable. That is, everything you've actually learned, everything you understand. If you're just mashing buttons, yeah, you might be a little lost when the buttons change. When telephones changed from rotary dial to push buttons, some people were still able to make calls. If course the basic syntax changed, and knuckle-draggers like the folks who modded the parent comment Insightful were SOL. But most folks who had some ideas about the THEORY of the telephone--that the little spinning disk on the phone didn't make the actual call but rather transferred information, and the buttons were just a new way of transferring the same information--adapted and moved on.

    The fact that a computer even let such a concept be typed and communicated gives me hope for the day when machines rule the Earth, that they just might have enough of a sense of humor, or pity, to allow us humans to remain in their midst.

    [ Parent ]
  • by fupeg (653970) on Wednesday June 07 2006, @03:40PM (#15490037)
    SQL is implemented differently in all of the environments I have encountered

    You confuse syntax vs. execution. Your statement is equivalent to saying that since C++ and PHP have different syntaxes, there is no point in studying algorithms or design patterns. Would you agree with this statement as well?

    All relational databases rely on predicate calculus at the end of the day. Understanding how relations work is fundamental to understanding what happens when you write something like "select A.x, B.y from A.B where A.z=B.z" Similarly understanding things like b-trees and hashing functions will aid you in both schema design and query optimization. Understanding the theory helps you make the right kind of design. Your design may be implemented differently on different DBs, but simply having knoweldge of a particular DBs syntax will not help you make the right design choices.

    [ Parent ]
  • Re:Useless to all but theoraticians (Score:3, Insightful)

    by sqlgeek (168433) on Wednesday June 07 2006, @03:41PM (#15490051)
    If you're worried about syntax variations across databases, then this is clearly not the book for you. However, once you're past syntax you need a book like this -- and I haven't seen another like it. The author is talking about how SQL works. What's the implication of using a correlated-IN clause vs. a correlated-EXISTS clause? Regardless of the syntax of a particular SQL dialect it is crucial that you understand these sorts of things unless you want to stare at the db blindly and wonder why it's slow.
    [ Parent ]
  • by AutopsyReport (856852) on Wednesday June 07 2006, @03:50PM (#15490105)
    SQL was created in the 1970's [wikipedia.org]. So it is possible to have many years experience with SQL. Heck, it was adopted as a standard in 1986. That is plenty of time to accumulate much experience with SQL.
    [ Parent ]
  • Re:Useless to all but theoraticians (Score:2, Interesting)

    by grrrgrrr (945173) on Wednesday June 07 2006, @04:07PM (#15490236)
    For theory books I think you may do better with a book that has litle to do with sql. I find Database in Depth by C.J. Date a nice theory book
    [ Parent ]
  • Re:SQL fun (Score:4, Interesting)

    by cruachan (113813) on Wednesday June 07 2006, @04:33PM (#15490405)
    Don't think I completely agree. True writing SQL to second-guess the optimizer in detail is deadly and pointless with modern rdbms' anyway (but Oracle 5, where you really had to isn't that many years ago). Nevertheless having a feel for how optimizers work is good. For instance setting up your joins on indexed fields or being aware of where the optimizer will use a full table scan and when that is a problem. On of my favourite tricks for example is to use an index to avoid a table access - which can pay mega dividends on large datasets. For example suppose we have a table which contains employee data and is index on an ID. I know that I regularly require a further field from this table - say insurance number. By setting an index on ID and Insurance Number the optimizer saves a record access for each instance when Insurance Number must be retrieved. That's a simple example, but the theme can be extended quite significantly
    [ Parent ]
  • by slamb (119285) * on Wednesday June 07 2006, @04:50PM (#15490519)
    (http://www.slamb.org/)
    This book might be good for THEORY, but for actually getting useful and applicable information, the review leaves me wondering who would be a worthwhile reader.

    That's funny, because I was just thinking it's odd that this book has no theory in it at all. At least in the review I saw no mention of the definition of ACID, the compromises at different transaction isolation levels, Codd's 12 rules for relational databases, Codd's original notation for relational algebra and relational calculus (of which SQL is an approximation), or normal forms.

    And it turns out that this theory is useful and applicable. If you haven't caught on yet, I'm disappointed by this omission. A lot of people write horrible systems because they do not understand transactions, how to normalize a database schema, or why constraints are so important.

    SQL is implemented differently in all of the environments I have encountered it (yeah, I'm not a PRO, just a hacker, so don't hate on me.) Those environments are MS SQL, MySQL, FoxPro, and MS Access. I think I messed around with PostgreSQL. Maybe a few others.

    Point is nothing is really transferable and even basic syntax varies widely as do optimizations and 'the best way to do x'

    If you need specifics on RDBMS implementations, look at this comparison website [arvin.dk]. It's not that long, and it basically fills in the gaps left by this book.

    You can usually write standard SQL statements and run them on PostgreSQL, MS SQL Server, Oracle, and DB2. You can certainly come up with Oracle statements that don't run on PostgreSQL - e.g., by using their alternate syntax for left joins that predates standardization - but presumably this book teaches you the standard stuff. That's all you need in most situations, and it's all they can give without you without having to update the book every six months.

    Microsoft Jet SQL (of Access fame) has a few cosmetic differences in syntax. (IIRC, quoting is different.) If that's enough to seriously set you back, you'd be in trouble even if the book did duplicate all the examples for you.

    MySQL is the only real oddball, and even they are starting to learn that this SQL thing is useful after all. If you want to work with older MySQL installations, get a book on MySQL, throw out any knowledge you have of how to do things properly, and give up on portability altogether. Peculiarities in its performance characteristics made projects like phpBB do bizarre things like mantain parallel table structures for each forum in a messageboard. That's totally against the relational model, and there are lots of consequences...

    [ Parent ]
  • by Laura_DilDio (874259) on Wednesday June 07 2006, @05:54PM (#15490915)
    Early in my career (before I become a Microsoft shill), I decided to forego learning SQL as a language and simply rely on MS Access instead.
    [ Parent ]
  • 9 replies beneath your current threshold.