Slashdot Mirror


The Art of SQL

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.

225 comments

  1. So According to the blurb... by Anonymous Coward · · Score: 0

    ... the reviewer has abolutely no idea what he just read?

    1. Re:So According to the blurb... by Anonymous Coward · · Score: 0
      "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.

      Just from reading that, I can tell that the reviewer knows exactly what he's talking about. Why I say this? Because I've worked with SQL myself. SQL is a language invented, by IBM, from a different time when there wasn't such a history of Computer Science.

    2. Re:So According to the blurb... by Anonymous Coward · · Score: 0, Funny

      He doesn't really have that much clue ...

      snippet:

      If you have very many years of experience with SQL,


      you can't have _many_ years experience, you may just have years of experience.
      many years sounds like 20 or 25 ... but emm, dudes, sql wasn't around yet.

      tomorrow we'll discuss C# with the developers who have 10 years of experience.

    3. Re:So According to the blurb... by Anonymous Coward · · Score: 0

      Bullshit... I was working with SQL on DB2 in the early 80's.

    4. Re:So According to the blurb... by Anonymous Coward · · Score: 2, Informative

      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.

    5. Re:So According to the blurb... by AutopsyReport · · Score: 1

      SQL was created in the 1970's. 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.

      --

      For he today that sheds his blood with me shall be my brother.

    6. Re:So According to the blurb... by Anonymous Coward · · Score: 0

      I've been working with SQL since 94 (12 years) - Microsoft SQL Server 4.2 on OS/2, no less. I know that SQL was around for quite a while before that because the standard used then was SQL-89.

      CJ Date's book was published in 1975, so I'm sure it was around before then, too. http://dblp.uni-trier.de/rec/bibtex/books/aw/Date7 5/

      Layne

  2. BN vs Amazon by beavis88 · · Score: 3, Informative

    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...

    1. Re:BN vs Amazon by larry+bagina · · Score: 0, Flamebait

      slashdot gets a BN kickback. (must be a pretty big one, too).

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    2. Re:BN vs Amazon by CRCulver · · Score: 1, Informative

      The book is not only cheaper at Amazon, but occasionally through the Third Party Sellers offering books there, one can get a mint book for pennies in comparison to the full price.

      In any event, Amazon's patents shouldn't intimidate Free Software fans, as the GNU project ended their boycott since there was no sign of danger.

    3. Re:BN vs Amazon by beavis88 · · Score: 1

      Yep, guess it's big enough that it outweighs the possible Amazon commissions lost to people like me that shop around :)

    4. Re:BN vs Amazon by CompiledMonkey · · Score: 1

      Amen to that. Amazon always has great deals when compared with everyone else.

    5. Re:BN vs Amazon by fm6 · · Score: 2, Insightful

      This isn't about software patents, or about prices. This is about who gives Slashdot the best deal for steering traffic to their site.

    6. Re:BN vs Amazon by mcmonkey · · Score: 1
      Well, I did a search at Amazon for this book by ISBN and got this.

      I did the same search at B&N.com and got the page for this book. Can't buy what I can't find.

    7. Re:BN vs Amazon by Anonymous Coward · · Score: 0

      Good for you to know that.

      I'm getting the book from Oreilly, The Art Of Sql (2006) Bbl Lotb.chm

  3. Useless to all but theoraticians by MBraynard · · Score: 0, Flamebait
    The authors almost never mention particular database products.

    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'.

    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.

    1. Re:Useless to all but theoraticians by stoolpigeon · · Score: 4, Insightful

      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.

      --
      It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    2. Re:Useless to all but theoraticians by kfg · · Score: 5, Insightful

      . . .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

    3. Re:Useless to all but theoraticians by mcmonkey · · Score: 1
      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.

    4. Re:Useless to all but theoraticians by truthsearch · · Score: 5, Insightful

      I disagree, but only to a small extent. I have extensive experience with MS SQL, Oracle, and mySQL. The basics of retrieving information are the same across all, but change very much when working on large systems. Select queries have to be written very differently on each system when tables get huge. For example, Oracle scripts with cursors are often much faster then regular joins if you know your data well. Yet on MS SQL cursors are the slowest way to go. On mySQL using temp tables in memory often outperforms outer joins, but not in the same cases as MS SQL.

      When working in the extremes the strengths and weaknesses of each system have to be considered.

    5. Re:Useless to all but theoraticians by fupeg · · Score: 1
      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.

    6. Re:Useless to all but theoraticians by sqlgeek · · Score: 2, Insightful

      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.

    7. Re:Useless to all but theoraticians by stoolpigeon · · Score: 1

      that makes sense. and i think there is a lot of value in becoming an expert on an rdbms. but think of the vast majority of databases, and the people working on them. i haven't run into many that weren't junk. in fact i'd be willing to wager, if there were ever a way to prove or disprove the assertion, that the vast majority of databases in existence are access databases made by people with no education in relational theory and the tables look just like spreadsheets.
       
      i just started a new job this week and i'll be working as a dba on a very large system running oracle. i'm really looking forward to it. it is a huge step up for me and i have a lot to learn. but i have no doubt that i'll also be putting in time on the side on much smaller projects and doing my best to explain to people why i have these 'crazy' rules about how to design a database or how best to get information out of it. many of these people will be developers-- i have no doubt of that.

      --
      It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    8. Re:Useless to all but theoraticians by grrrgrrr · · Score: 2, Interesting

      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

    9. Re:Useless to all but theoraticians by MBraynard · · Score: 1
      I do have a degree in MIS, so all of the relational stuff (3rd normal form, etc.) is old hat to me - but I didn't NEED to go to school to learn this and it's relatively obvious to anyone who does it for a while of what works best. Very self-evident.

      You don't need a whole book for this - you need a magazine article. A whole book on theory is much less useful than maybe a book with a chapter on theory and a whole lot of chapters on practical appications specific to a given engine.

      The problem is that the differences in the engines reach SO DEEP and affect so much that you actually could have a book on theory - for each one of them.

    10. Re:Useless to all but theoraticians by Nemi · · Score: 1
      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.

      Grevious? As in General Grevious? You were thinking of the lightsaber post above, weren't you?

      Were you thinking of grievous perhaps?

    11. Re:Useless to all but theoraticians by russotto · · Score: 1

      Exactly. In theory, you can write good SQL and each system will do the right thing. In practice, that ain't the case. For instance, I had a query which joined a bunch of tables together to come up with a small result set containing duplicate rows. Ran fine, but I wanted to get rid of the dupes. Add "DISTINCT". Whoops, all of a sudden the query takes forever. "Explain Plan" tells me it's now for some reason ignoring indexing and doing full table scans and that sort of thing. The "solution" was an ugly hack like

      SELECT DISTINCT foo, bar, baz from (SELECT foo, bar, baz from ...))

      explicitly telling it to create the result set and THEN eliminate duplicates

      Contrariwise, the original query performed fine with an ORDER BY clause -- and if I added a "DISTINCT" to that one, it continued to perform fine.

      Tell me that sort of thing is applicable across databases. Actually, please don't. I don't do queries any more and I'm glad of it.

    12. Re:Useless to all but theoraticians by kfg · · Score: 1

      . . .but I didn't NEED to go to school to learn this . . .

      Who said anything about going to school? I am a vociferous advocate of the library fine model of education. Most of what you learn in school these days, even at the tertiary level, is just plain wrong. At least in math, physics and chemistry we still require that you test and verify what's in the text book at the lowest levels.

      . . .you actually could have a book on theory - for each one of them.

      And here it is, written from the point of view of the practioner:

      Practical Issues in Database Management

      Perhaps if you read it you will gain a better understanding of the very concept of "theory." Your comment reveals you to be a bit weak on this point.

      KFG

    13. Re:Useless to all but theoraticians by kfg · · Score: 1

      I am a certified dysxleci and dysgraiphc. The testing standards are very strinjint.

      KFG

    14. Re:Useless to all but theoraticians by ad0le · · Score: 1

      SELECT FIELD FROM TABLE GROUP BY FIELD HAVING COUNT(FIELD) > 1

      Works ON MySql, MSSQL, Oracle, PostgrSQL, DB2, SqlAnywhere, MaxDB etc etc etc.... dupes are easy to find using ANSI Sql, and most other stuff is as well

      --
      My mother never saw the irony in calling me a son-of-a-bitch.
    15. Re:Useless to all but theoraticians by slamb · · Score: 1
      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. 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...

    16. Re:Useless to all but theoraticians by cruachan · · Score: 1

      In my experience there's a point in all rdbms systems for table size which once crossed causes significant differences in table handling and requires serious DBA skills to optimize the system correctly. Generally this seems to be in the region of 200,000 to 1,000,000 records. Below that as long as you are paying reasonable attention to indexes you are fine, above that it's important that the dba understands quite deeply the table structure, data, indexes and access methods, and otimizes correctly.

      There's a multiplicity of reasons why this might be so, but it's quite noticable sometimes how a relatively small increase in table size can move a table over the edge from being trivial to handle to requiring some insight.

    17. Re:Useless to all but theoraticians by Laura_DilDio · · Score: 1

      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.

    18. Re:Useless to all but theoraticians by abirdman · · Score: 1

      I know that Transact SQL book you're talking about, and thought of it when I read this review. That's the best book on SQL I've ever read (by far) and I learned more about Oracle SQL from reading it than I have from reading at least a dozen more specifically Oracle-centric books. Fantastic book, I think it's called Advanced Transact SQL or some such. There's some proprietary stuff in there that's specific to MS SQL, but mostly it's a great overview of various ways to get a specific result set, and various ways to deal with problems that arise-- duplicates, nulls, poor performance, strange data relationships, etc., and it has a good discussion of functions and stored procedures as well.

      Good luck with your new Oracle career. I wish our DBA knew SQL!

      --
      Everything I've ever learned the hard way was based on a statistically invalid sample.
    19. Re:Useless to all but theoraticians by MBraynard · · Score: 1

      Kinda snooty there, aren't we?

    20. Re:Useless to all but theoraticians by kfg · · Score: 1

      Snooty? No, not really. Elite? Absolutley.

      One of the reasons I am not actually snooty is because I do not seek to look down from my elite platform, I seek to help people up to it. I am elite, but not elite-ist.

      If only because it would make my own life a damned sight easier.

      The essential problem is, and where the appearance of snootiness can come from, is that I first have to make people understand there is something above them. Sometimes, for some people, it takes a wack upside the head. If you do not understand that you do not know you will never seek to learn. To learn you must accept that someone else has superior knowledge. That you are in that limited respect their inferior.

      And for some people joining the elite simply isn't within their capabilities. That isn't snootiness. That's reality. I'll never run hurdles like Edwin Moses either, no matter how hard I train; and that's the way it is.

      But if I chose to run hurdles you can be damned sure I'd supplicate Edwin to give me some pointers, unabashed in acknowledging him as my superior.

      KFG

    21. Re:Useless to all but theoraticians by MBraynard · · Score: 1

      No, YOU'RE a towel!

    22. Re:Useless to all but theoraticians by kfg · · Score: 1

      I'd always know where I am if I were you.

      KFG

    23. Re:Useless to all but theoraticians by russotto · · Score: 1

      That gives you the dupes; I was trying to eliminate them. This is perfectly easy to do in portable SQL --

      SELECT DISTINCT fields FROM tables WHERE hairy join clauses and conditions

      The problem wasn't that it didn't work; the problem is that the optimizer did something stupid and made it take forever. Because the result set was far smaller than the tables, the fastest way to do the DISTINCT query was to do the ALL query and then filter the results. But for some reason Oracle did something completely different, involving lots of full table scans. I had to write a hack to trick it into doing the right thing.

  4. art by Lord+Ender · · Score: 4, Insightful

    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 for a start on the science of databases.

    *Yes, I know creativity is usually involved when designing things. That doesn't make it art.

    --
    A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    1. Re:art by Anonymous Coward · · Score: 1, Insightful

      You must be one miserable bastard to work with.

    2. Re:art by Mindwarp · · Score: 2, Funny

      A slashdotter who did not build his own computer is like a jedi who did not build his own lightsaber.

      Imaginary?

      --
      The gift of death metal does not smile on the good looking.
    3. Re:art by gowen · · Score: 2, Insightful

      There's a difference between something being an art and something being art.

      Science, yes even computer science, and mathematics are particularly susceptible to elegance, and science (and engineering) built on elegant designs, based on concrete principles, have fewer points of failure, and can often be conceptually simpler, and algorithmically faster. Art is simply the application of insight, and this book (seems) to show us how insight into the problem space and the mathematics can achieve elegant (and efficient) designs.

      Having said that, I know nothing about SQL, a bit of database theory and a lot of set theory. Also, that book review was far above the usual /. standards, where book reviews look more like book reports. Here's to you, SQL-book-reviewing-guy.

      --
      Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
    4. Re:art by Anonymous Coward · · Score: 0

      I agree, art is an overused word.

      It is strange that most people have no respect for those who choose to be artists (believing them to be losers), then try to label an analytical task (done using the other side of the brain) "artistic", in order to make it sound like a better accomplishment.

      Since what is "art" is subjective, you can call SQL an art, but it carries little meaning.

    5. Re:art by Vellmont · · Score: 1


      Designing proper databases and the SQL to use them optimally falls under the domain of science/engineering.

      The process of doing science isn't as clear cut as you're trying to make it out to be. You're thinking of science as the nice, clean end product that's been checked and written in textbooks. Getting those results can most certainly be an "art" (that is something learned by experience, and not easily definable). Working with something as complex as a database is similar in that the performance you get from different databases isn't always so easy to define. Databases are among the most complex pieces of software out there, so it should be no surprise that some people see working with them more art than science. There's really no call for calling anyone who sees the world differently than you do "a hack".

      --
      AccountKiller
    6. Re:art by msuarezalvarez · · Score: 1

      Donald Knuth says in the foreword to the "A=B" book by Marko Petkovsek, Herbert Wilf and Doron Zeilberger (which is essentially the solution of Knuth's exercice 1.2.6.63!):

      Science is what we understand well enough to explain to a computer. Art is everything else we do.

      That's a high bar!

    7. Re:art by Ruie · · Score: 1
      *Yes, I know creativity is usually involved when designing things. That doesn't make it art.

      But adding cavities to design of nitrogen chilled supercomputer so you can cool things there does.

    8. Re:art by Maxo-Texas · · Score: 1

      I think it could be an art-- but today it is mostly automatic optimizers that tune databases.
      Some of the tunings are counter-intuitive.

      Clearly any complex setup with multiple tradeoffs and ill-defined specs requires a bit of an artist to set up. Your wiki link was nice, but many businesses don't budget enough money to do it that rigorously.

      --
      She was like chocolate when she drank... semi-sweet at first and then increasingly bitter.
    9. Re:art by RoadWarriorX · · Score: 1
      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.


      As a developer, I could not agree with you more! Using a database is a real pain in the a$$ for developers. We have to embed an entire complex, cryptic language in our programs so that we can get simple data. We have to create a heirarchy of object-relational mappings just to be able to use the data effectively. DBA's want us to use stored procedures to abstract, but these SP's end up containing complex business logic that make it very difficult to refactor. Geez, it just makes me want to put everything in flat-files!
    10. Re:art by Anonymous Coward · · Score: 0

      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.

      Did you go to engineering school? If you did, you would know that engineering IS an art, not a science. Look it up.

    11. Re:art by Tablizer · · Score: 1

      In theory isn't the SQL parser supposed to find the optimim execution path? The whole idea of logic programming is to ask for what you want and then let the computer determine the optimum execution path and technique through math and logic deduction. Otherwise, we might as well write explicit loops. This is suppose to shift the performance burden to the parser builders instead of the query writers (users). I agree that in practice it is not always so easy, but isn't this the end goal?

    12. Re:art by Anonymous Coward · · Score: 0

      Many of those 95% are working on systems whose designers believed that databases are simply means for a persistent data store, and in the context of those systems, that is all they are.

    13. Re:art by syousef · · Score: 1

      The scary thing is that you truely believe this.

      Very very few things beyond a basic theoretical physics or chemistry problem can be solved with pure science. Science is the start. You can't play ball just because you know the laws of physics. I'll use one of my favourite analogies. A good aircraft pilot has more than just a grasp of the physics and mechanics of his aircraft, airspace procedures etc. It's definitely as much art as science and the best pilots don't do everything by numbers or rules. Another example: Bridge building. There might be 10 types of bridge that will solve your technical problems of getting cars across a stretch of water but the engineers and architects have to be mindful of the surroundings, and get a feel for what the place is like and what people will want to see built - at least the good ones will.

      It is the same with database design. You have to have a good deal of intuition about what the database will be used (and misused) for. You have to make tradeoffs between efficiency, space and redundancy that each have advantages or disadvantages.

      Science is crucial and there's no excuse for not having a good understanding of the science behind your chosen profession, but it's just the beginning. If you choose to think I'm just a smelly art student with a penchant for computers, think again. I have a Masters in Astronomy.

      --
      These posts express my own personal views, not those of my employer
    14. Re:art by Lord+Ender · · Score: 1

      Designing software is an engineering discipline which is best performed by people with foundations in science.

      First I'll quote myself again, because you seem to have missed it:
      "*Yes, I know creativity is usually involved when designing things. That doesn't make it art."

      Then I'll ask you the same question I asked some other guy:
      Have you worked with someone who thinks programming is an "art?" They strive for cleverness, complexity, and originality. Those are the exact opposite of good engineering principles.

      So did you study engineering? I'm thinking no. I think you missed the word "engineering" in my first post.

      But go ahead and be a code artist. Do things in creative ways instead of using the known-best ways. Ignore engineering principles. The file is your canvas.

      And if I ever edit your oh-so-clever code, I'll curse you the entire time. If I ever try to extend your architecture, only to find it is too interconnected to do so, I'll tell management exactly why the app needs to be rewritten from scratch (because you were being an artist).

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    15. Re:art by syousef · · Score: 1

      So did you study engineering? I'm thinking no. I think you missed the word "engineering" in my first post.

      Fuck I hate that about /. and newsgroups and the Internet in general. What do you know about my goddamn background besides what I've told you? No i haven't studied engineering. My degrees are in Computer Science and Astronomy. Guess what people without the same background as yourself are entitled to an opinion.

      But go ahead and be a code artist. Do things in creative ways instead of using the known-best ways. Ignore engineering principles. The file is your canvas. (rest of rant removed)

      Did you even read anything I wrote? I said science was REQUIRED but on it's own it wasn't enough. The art in building programs is not in making them clever or creative. The art is in making design the correct design choices - so that the code can evolve with changes in the needs of the user (which you have to predict to some extent), but without making it so flexible that it's complexity is the epitomy of the phrase over engineered.

      Next time try arguing against the actual argument posted for christ sake instead of going on about how superior you are because you use engineering principles which I've supposedly shunned (when I said no such goddamn thing).

      --
      These posts express my own personal views, not those of my employer
    16. Re:art by Lord+Ender · · Score: 1

      I guess I missed your point.

      My original point was that designing software systems was an engineering discipline, not an art-form.

      You countered, saying it was scary that I believe that. Then you made some pointless statements about flying and bridge building. By pointless, I mean that flying is not at ALL similar to designing a functional system, and that designing a bridge is a very well-established form of engineering. No sane person would hire a "bridge artist" to determine the thickness of the beams needed in a bridge.

      Since there wasn't much point in arguing with your pointless analogies, I backed up my previous statement with some examples of why the artist mindset is the wrong one for software design.

      You countered again saying I should have attacked your argument.

      It seems you and I have vastly different ideas of what art and engineering are. I have studied engineering, and you have not. For this reason, I think my ideas are more credible than yours. I will repeat them, if you like:

      The artist strives for things like originality and creativity. The engineer strives for predictable, repeatable, systems-oriented designs. Those are very different goals. Some creativity is required when engineering, but it is not a goal by itself.

      So what is your problem with that? That is scary to you?

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    17. Re:art by syousef · · Score: 1

      I guess I missed your point.

      I guess you still do.

      My original point was that designing software systems was an engineering discipline, not an art-form.

      And my point was that it's so complex and strewn with human factors that you can't rely on engineering alone. The science and engineering are necessary but the design when faced with a multitude of equally technically valid choices comes down to predicting how the system will grow and evolve. There's some science on that but it's incomplete and hard to apply.

      You countered, saying it was scary that I believe that.

      Yes. It's very scary you think you can apply pure theory that way. You're either inexperienced, or an academic or both.

      Then you made some pointless statements about flying and bridge building.

      They were only pointless in that they were lost on you.

      By pointless, I mean that flying is not at ALL similar to designing a functional system, and that designing a bridge is a very well-established form of engineering. No sane person would hire a "bridge artist" to determine the thickness of the beams needed in a bridge.

      That's right. You use the science to determine thickness of the beam or you get a bridge that collapses. You use an ARCHITECT to choose one of the many designs that will fit into the landscape well and be aesthetically appealing.

      See now that wasn't so pointless was it.

      Since there wasn't much point in arguing with your pointless analogies, I backed up my previous statement with some examples of why the artist mindset is the wrong one for software design.

      And you've not countered a single argument I've made. All you've done is state that they're pointless.

      You countered again saying I should have attacked your argument.

      Yes and you still haven't.

      It seems you and I have vastly different ideas of what art and engineering are.

      This isn't a problem of definitions. That's just a poor attempt at distraction. In any case if it was an issue of definitions, you could try giving me your definition, but you haven't even bothered to do that. A dictionary would solve that problem for you.

      I have studied engineering, and you have not. For this reason, I think my ideas are more credible than yours. I will repeat them, if you like

      I work as a software engineer you insulting fool. I've done a computer science degree. I'm much more qualified than you to be speaking about software. Saying something this stupid reflects badly on you. Your attitude in general stinks - people are allowed to have an opinion regardless of their qualifications.

      Also I'd get my money back on an education that doesn't teach you how to make a coherent argument without trying to distract from the fact that you don't have one.

      The artist strives for things like originality and creativity.

      If that were true there wouldn't be such things as schools of art. You do realise there's scientific technique to art as well don't you. You don't just pick up a paint brush and paint a masterpiece. You learn how different techniques with your brush give different results etc. and apply that. Art and science are not nearly as separate as you make out.

      The engineer strives for predictable, repeatable, systems-oriented designs.

      So does a good artist. A good painter might paint the same scence 10 different ways, experimenting with different techniques.

      Those are very different goals. Some creativity is required when engineering, but it is not a goal by itself.

      No they're not. You seem to have something hard wired in your brain that says creativity and applying fixed well known techniques are mutually exclusive. That's just nonesense. Leonardo Divinci was both an artist and a scientist and he's not the only one. Have a look at some of his mechanical designs if you think art and science are mutually exclusive. one design prempts the invention of the helicopter.

      --
      These posts express my own personal views, not those of my employer
    18. Re:art by bnortman · · Score: 1

      SQL is an art form that can be expressed in so many different ways. However, its can be a science since only a few versions will perform optimally. It is key to examine all the possiblities and look at how the "Machine" interprets the art. You can do this using execution plans and statistics.
      Here are a couple of articles from Richard To on Optimizing SQL
      Why Join Path Matters http://www.extensibles.com/modules.php?name=Forums &file=viewtopic&t=12
      Is SQL Optimization a Unsolvable Problem http://www.extensibles.com/modules.php?name=Forums &file=viewtopic&t=25

    19. Re:art by Lord+Ender · · Score: 1

      So bitter... It is among the most vicious personal name-calling I've been lucky enough to experience in a very long time.

      At your request, I consulted a dictionary. It seems "art" has so many definitions it is almost pointless to talk about what art is. But at least one of the definitions of art is mostly exclusive with the definiton of engineering:

      art1 (ärt) pronunciation
      n.
            5. A nonscientific branch of learning; one of the liberal arts.

      engineering (n'j-nîr'ng) pronunciation
      n.
            1.
                        a. The application of scientific and mathematical principles to practical ends such as the design, manufacture, and operation of efficient and economical structures, machines, processes, and systems.
                        b. The profession of or the work performed by an engineer.

      And I realize that software engineering is among the least mature engineering disciplines. But for 95% of software engineering projects, the GOAL of those designing software should be to strive for engineering priciples similar to those employed in the more mature disciplines. If the goal of these system designers is to be "artistic," they are in many ways at odds with that.

      For the very small number of ground-breaking research areas in information technology, the philosophies of engineering are less important. Once these areas mature, engineering should be more important.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    20. Re:art by Lord+Ender · · Score: 1

      What you are decribing seems a lot more like science than art.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    21. Re:art by syousef · · Score: 1

      So bitter... It is among the most vicious personal name-calling I've been lucky enough to experience in a very long time.

      Oh honestly what did you expect? Your argument was that my point of view was invalid, and my opinion irrelevant, because I'm not an engineer. I studied computer science for goodness sake. This is much more my field than yours. If you tell someone they have no right to give an opinion on the area they've studied and make a living out of, do expect some retaliation.You most definitely earnt being called arrogant and rude. If you've done this before and haven't had any it's probably because whoever you did it to decided you were not worth the time.

      art1 (ärt) pronunciation
      n.
                  5. A nonscientific branch of learning; one of the liberal arts.


      Oh come on, you had to go to the 5th dictionary definition, which actually uses the word that's being defined as part of the definition to back your argument. Very poor and very weak. I notice the definition of engineering is the very first one.

      For the very small number of ground-breaking research areas in information technology, the philosophies of engineering are less important. Once these areas mature, engineering should be more important.

      Oh no engineering - being aware of and using the laws of nature to ensure what you're building will work are always important if you're building something. I never said they weren't. I never said ignore the science and engineering. What I said was both art and science are imporant. Science has it's limits and is a tool. What can't be done by adhering to strict rules can often be done using techniques and heuristics best described as art.

      You can observe the political and social climate of the stakeholders for the system you're building and make design choices - make the system flexible - based on what you think the future needs of the system will be. There is no science that can predict human interaction this well. It is definitely more an art than a science. Science/Engineering requires you adhere to strict rules. The closest science here is pyschology and I'll tell you it's no where near as effective as having a good software engineer follow their gut.

      Once again you've ignored the vast majority of what I've said

      --
      These posts express my own personal views, not those of my employer
    22. Re:art by Anonymous Coward · · Score: 0

      "Geez, it just makes me want to put everything in flat-files!"

      Please Sir,
      Step away from the IDE, go to the local grocery store and buy a six pack. It helps ease the pain, as I too feel the same way.

    23. Re:art by dankelley · · Score: 1

      Isn't science the study of nature? Designing good SQL might be an engineering activity, akin to designing good toothbrushes, but it's not at all related to science.

    24. Re:art by aevans · · Score: 1

      Art is simply putting paint on a brush and then smearing it around until it looks like something. I don't know what dictionary your reading from. Oh, wait there's another definition-- nevermind, it says "see Garfunkle, Art"

  5. Great Statement by lbmouse · · Score: 3, Funny

    "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 and a rubber hose.

    1. Re:Great Statement by msuarezalvarez · · Score: 1

      SQL is a declarative language, not a procedural one. It is in that aspect related to functcional and logic programming languages. SQL code describes what you want to get, not how to get it. That is the actual intent of the design.

  6. Where's the news? by Graboid · · Score: 0, Offtopic

    Book reviews seem so out of touch with the flow of the rest of Slashdot (except to the extent that everyone can comment about stuff they haven't read).

    Could Slashdot not post book reviews to the main section?? At least not at the same level as a news story that locks Slashdot for an hour - maybe just a sentence "Art of SQL review" with a link then post a real news story as well.

    The reviews are neither timely news nor really commentable (although that rarely stops us).

    I quite like having the section and appreciate the time the authors put into these reviews (and have bought a couple because of that), but they shouldn't be mixed into the news postings.

    1. Re:Where's the news? by PCM2 · · Score: 3, Informative
      Could Slashdot not post book reviews to the main section??

      I like book reviews.

      Homepage preferences are your friends.

      --
      Breakfast served all day!
  7. Re:MOD UP if the new Slashdot HTML sucks by GmAz · · Score: 0, Offtopic

    Ya, its off topic, but you are right. This new slashdot is nice and all, but stuff needs to go where it belongs.

    --
    Click Click Bloody Click PANCAKES!
  8. Bummer, trees by plopez · · Score: 3, Insightful

    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

    --
    putting the 'B' in LGBTQ+
    1. Re:Bummer, trees by stivi · · Score: 1
      Well, I have not read the book, but I think that by trees they mean hierarchical structures, usualy implemented in one table: id_employee | id_superior | employee_name | ...

      Keyword for traversing such structure is CONNECT BY.

      --
      First they ignore you, then they laugh at you, then they fight you, then you win.
    2. Re:Bummer, trees by Bogtha · · Score: 1

      Trees are of limited value, they only exist in special circumstances.

      Yes, in fact, I'm struggling to remember the last time I saw a tree structure, as I post one of many replies to your comment, which in turn is one reply of many to the article.

      Trees crop up in all kinds of different places, and the approaches most newbies tend to take are awful. That warrants their inclusion in a book like this. I agree that many-to-many relationships are important, but that's no reason to neglect tree structures.

      --
      Bogtha Bogtha Bogtha
    3. Re:Bummer, trees by plopez · · Score: 1

      But are they a natural artifact of a conversation or because people just can't wrap there heads around a different structure becase that is all they were ever taught.

      I for one am very frustrated with constant drilling down through file structures, conversation threads, posting comments which associate across different parent posts conceptualy but I have to post twice if the point is relevent to 2 source posts.

      A cloud view based on meta data and linking would be nice. Almost like, date I say it, relationships between web pages? Why parent child? Why a heirarchy? No good reason, really.

      We must free our minds from the slavery of trees... :)

      --
      putting the 'B' in LGBTQ+
    4. Re:Bummer, trees by Anonymous Coward · · Score: 0

      The problem with SQL is that anything beyond the insanely easy is obscenely complex. Which is why a whole bunch of simpletons are so religious about it and say stupid shit like the parent.

    5. Re:Bummer, trees by eh2o · · Score: 2, Informative

      FYI this book does mention many-to-many relations a few times, including its implications for multiple indexing and in the chapter on trees (since graphs are a generalization of trees where a node may have multiple parents). In the book there are 4 different data structures proposed for trees.

    6. Re:Bummer, trees by Bogtha · · Score: 1

      But are they a natural artifact of a conversation or because people just can't wrap there heads around a different structure becase that is all they were ever taught.

      I believe that they aren't a natural artifact of a conversation, but nobody has come up with a decent interface for multi-parent comments. There have been attempts, but they all end up being too confusing for very little gain. Comment trees are the optimum balance between complexity and usability.

      --
      Bogtha Bogtha Bogtha
    7. Re:Bummer, trees by sqlgeek · · Score: 2, Informative

      Didn't look at the sample chapter, did you? It deals with a many-many relation several times in varying contexts.

    8. Re:Bummer, trees by dbdweeb · · Score: 3, Insightful

      You ARE just being facetious right?

      Tree structures are everywhere in computing... Like file systems... Like the DOM for every web page you have ever looked at is represented by a tree structure.

      As regards the coverage of M:M... Another post pointed out that it IS covered in the book.

      As regards the usage of M:M... That's just for high level conceptual modeling right? Surely you are not actually going to implement that way but will instead insert an intersect object AKA associative table, right? Database Programming 101 thorough covers this topic.

      Not only do DUH velopers need to stop thinking of the RDBMS as just a bucket to hold stuff, they desperately need to be know SQL and aspire to database programming beyond cutting more code. And even more significantly, they need to understand the importance of a good ERD so they don't fall into the trap of trying to implement a M:M.

    9. Re:Bummer, trees by cruachan · · Score: 1

      You havn't the faintest idea what you are on about have you? While SQL does have it's faults (but less so with more modern standards) it is a truly elegent method of retrieving and manipulating data. SQL can be difficult to grock for many coders because it's declarative and not procedural.

      One trick I have with newbie sql coders is to make them think about the statement

      select * from tblA, tblB

      and compare to

      select * from tblA, tblB where tblA.key = tblB.key

      Easier to see what's going on with the original SQL specification I think - anyway the insight that the first statment is a cartesian join and gives you the set of A multiplied by B, whereas the second is logically the same but after the cartesian join the records not meeting the where clause are excluded (filtered) seems to start people off on the route of understaning what SQL is. (and yes I know the optimzer would never assemble the cartesian then filter, but the point is a feel for how the set operations work logically, not the algorithmic details)

    10. Re:Bummer, trees by Electrum · · Score: 1
      select * from tblA, tblB

      and compare to

      select * from tblA, tblB where tblA.key = tblB.key

      Both of those are clearer when written using standard join syntax:

      SELECT * FROM tblA CROSS JOIN tblB

      SELECT * FROM tblA JOIN tblB USING (key)


      Or if the column names are different:

      SELECT * FROM tblA JOIN tblB ON (tblA.key = tblB.key)
    11. Re:Bummer, trees by Anonymous Coward · · Score: 0

      like I said...

    12. Re:Bummer, trees by Anonymous Coward · · Score: 0

      No, you simply can't implement a tree based discussion, without giving up your first born, using a relational system, and that is your bias.

    13. Re:Bummer, trees by abirdman · · Score: 2, Insightful

      I basically agree with your post, but you're overlooking a significant part of the audience for this book -- people who didn't design the data structures they're querying. You're absolutely correct that tree structured data is a terrible hack in most databases, but if you're writing reports, or writing code to update legacy data, or the data was converted from another system altogether (perhaps written in Cobol or Quick Basic or some horrible old language where hierarchical data was a way to wring out some performance), then it's good to know ways to access it.

      My specialty for the past 15 years or so has been conversions and writing applications that glue together multiple systems and data formats. What I'm most interested to learn (and I'm still learning every day) is what's the best way to get a desired result set from the data that exists, as it exists. If I had designed the data architecture in the first place, it wouldn't be a problem.

      I'd be willing to bet that most of the SQL that exists is written by people who didn't design the data structures. Most of the relational data that exists wasn't originally designed for the relational database in which it's stored. Terabyte databases (even Gigabyte databases) aren't always populated with clean, 3rd normal form data-- they're messes of OLTP data, optimized for some oddball data entry scheme, converted flat tables from some branch offices, the data warehouse some consultants put together 10 years ago just before they got fired or moved on to other projects, a nightly feed from overseas, a weekly bank account reconciliation, etc., etc.. SQL can glue all this data together, and allow relating otherwise discrete data and getting meaningful information out. For me, the more theory I can learn to understand what data is there, and how to relate it to the company's other data, the better I can do my job.

      And yes, we do design, test, and deploy conversions and data re-factoring, when time and resources permit. We also do Oracle upgrades, regular OLTP system updates and maintenance, and test and update various front-ends, from Business Objects, to .NET, to FoxPro.

      --
      Everything I've ever learned the hard way was based on a statistically invalid sample.
    14. Re:Bummer, trees by cruachan · · Score: 1

      I generally use an explicit

      SELECT * FROM tblA INNER JOIN tblB ON tblA.key = tblB.key

      as I like to make my joins clear. However the point I'm making is that this syntax make you think along the lines of the results dataset being assembled by joining groups of records, whereas there's quite a deep logical insight to be had by thinking of all the table joins as cartesians which generate a dataset which is then 'filtered' by the join conditions.

      Your milage may vary of course, but when I first started using SQL I found this quite a useful concept for getting my head around SQL's set behaviour. Indeed I'd go so far as to say to understand SQL you really have to grock why select * from tblA, tblB gives you a recordset of tblA * tblB.

    15. Re:Bummer, trees by Elwood+P+Dowd · · Score: 1
      As regards the usage of M:M... That's just for high level conceptual modeling right? Surely you are not actually going to implement that way but will instead insert an intersect object AKA associative table, right?
      Uh... is there some other way to implement a M:M relationship? Some way besides an association table?

      It's so weird being at my particular middling level of SQL proficiency. I can never tell if I don't understand people talking about SQL on the web because they have ten times the understanding I do (they work at Amazon & frequently use normal forms I've never heard of), or because they don't have a tenth of the limited understanding that I do (never been acquainted with a relational diagram of any kind).

      The only person that I know with whom I can talk about SQL and understand anything is one of my coworkers. But both of us know that we're often stabbing around in the dark trying to find the right answer for our weirder joins & whatnot. If you see what I mean. 'Scuse the rambling.
      --

      There are no trails. There are no trees out here.
    16. Re:Bummer, trees by cruachan · · Score: 1

      You're probably just trolling, but seriously, if you really do think this then you are in the wrong profession as you obviously don't have the mental capacity of rigour needed to code beyond a very basic level.

    17. Re:Bummer, trees by Sigg3.net · · Score: 0

      Trees are of limited value, they only exist in special circumstances.

      I think you'd find it hard to breathe without'em.
      As for special circumstances, I think we all could benefit from a walk in the woods every now and then.

    18. Re:Bummer, trees by dbdweeb · · Score: 1

      There's no reason not to implement an association table is there? It's true that some transactions may require you to update 2 tables instead of one but the "alternative" of having one column contain one or more delimited values is bad form requiring you to manipulate data outside the database engine. To make things easy you can use triggers to do things like cascade deletes on association tables, etc. Of course using triggers raises RDBMS portability issues.

      There is sometimes a bit of art to data modeling but generally recognized best practices are a safe bet and 3rd normal form usually does the trick.

    19. Re:Bummer, trees by Elwood+P+Dowd · · Score: 1
      There's no reason not to implement an association table is there?
      Not that I know of.
      but the "alternative" of having one column contain one or more delimited values is bad form
      Yeah, see, never would have occurred to me. And screw portability: ON DELETE CASCADE better have an analog on any RDBMS I use, otherwise I can't imagine being able to keep all my balls in the air.
      --

      There are no trails. There are no trees out here.
  9. Re:MOD UP if the new Slashdot HTML sucks by mobby_6kl · · Score: 1

    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, making it a little ugly/difficult to read.

  10. One year of SQL is significant experience? by Osty · · Score: 3, Insightful

    Perhaps that's what's wrong with database development these days (just check out The Daily WTF, 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.

    1. Re:One year of SQL is significant experience? by plopez · · Score: 1

      In most areas, 3-5 years is the minimum.

      This goes for trades as well as engineering. The EIT paradigm used in engineering requires logging hours under a licensed engineer for what amounts to a 3 r more year apprenticeship.
      Most trades programs do not allow you to be called 'Master' until after apprenticeship and being a journeyman for a few years.

      The upshot being that most plumbers are probably better trained than IT people.

      And the posts on this board prove it. Also, as bad as the review was, it gave me enough information to *not* buy the book (hint: I never buy books that mention Celko in a positive way and I never buy books that are married to the concept of heirarchical data). The authors sound too much like SQL monkeys to me.

      --
      putting the 'B' in LGBTQ+
    2. Re:One year of SQL is significant experience? by truthsearch · · Score: 1

      FWIW, I have 10 years of experience with Oracle and MS SQL and I still don't consider myself an expert. I wrote reporting queries against one of the largest Oracle databases in the US and our truely expert DBAs were always teaching me something new.

      Some people talk to me about databases like I'm Yoda. But I label myself as "very experienced." When performing the right kind of work I'd say it takes at least 4 or 5 years to gain significant experience.

    3. Re:One year of SQL is significant experience? by geekoid · · Score: 1

      so you only look for people who ahve been coding in C# since 2001? I guess you only look a resume of MS emploee's who where on the project thatc reated it...

      I assume you mean MSSQL7-MSSQL2005. Which is a horrible database to learn on. I have used almost every version, and Oracle is a lot better. Of course Informix could out perform both of them, but I digress.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    4. Re:One year of SQL is significant experience? by Osty · · Score: 1

      so you only look for people who ahve been coding in C# since 2001? I guess you only look a resume of MS emploee's who where on the project thatc reated it...

      As I recall, Visual Studio.NET shipped in 2001, which would mean someone could have 5 years of C# knowledge this year (2006). Also, there were public betas of C# and the .NET framework prior to the shipping of VS.NET. Besides all that, I see you got my joke (requiring 5-6 years of experience in a technology that's only been around for 4-5 years).

      I assume you mean MSSQL7-MSSQL2005. Which is a horrible database to learn on. I have used almost every version, and Oracle is a lot better. Of course Informix could out perform both of them, but I digress.

      Yes, Microsoft SQL Server. I think you should qualify your statement, though. MS SQL Server is a horrible database to learn on if your goal is to ultimately work with Oracle databases. That's a sad fact of the database industry today -- all of the big players are incompatible with each other at some level. None of them implement the full SQL-99 standard (or even the full SQL-92 standard), and all of them implement their own special way of doing things (canonical example: creating an auto-increment column). However, MS SQL Server will at least teach you the basics you'll need on any other system, same as learning on any other good database. If you want a real example of a bad database to learn on, you need look no further than MySQL.

  11. Developers and SQL by DebianDog · · 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

    1. Re:Developers and SQL by cpt_rhetoric · · Score: 1

      ROFL. I remember see code once in MS SQL, where this developer opened a cursor on a table to find the row that had a particular value he wanted, he would then take the id for the row and then basically select from the very same table where the id for that row was the id he got from step #1. Typically though, this type of coding came from ABAP developers who suddenly found themselves coding in a non SAP environment.

    2. Re:Developers and SQL by NoOneInParticular · · Score: 1

      Why is it not a database problem? Wasn't the whole point of SQL that you could state the result you wanted in a declarative manner and let the database figure out how to get you your result fastest? If it can't, why the hell do we need to write SQL, as I do now how to traverse an indexed btree fast using a simple loop or recursive algorithm? What's that layer doing there apart from being a pain in the neck?

    3. Re:Developers and SQL by Pfhreakaz0id · · Score: 2, Interesting

      and as a developer, I will counter, that, in my experience, the reason there was a 5-page sql query in the first place was because the DBA had very restrictive rules about normalization (not realizing that denormalization is a common, industry-standard way to improve database performance). Why did my query (this was at my last job, which had the dba's from hell) have 16 joins in it? Because I had to split stuff up across 6 tables that I knew I would always be accessing at the same time anyway...

    4. Re:Developers and SQL by Fulcrum+of+Evil · · Score: 2, Informative

      Why is it not a database problem?

      Because it's a 5 page SQL query.

      ...how to get you your result fastest?

      Sometimes, fastest still takes a long time.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    5. Re:Developers and SQL by GoofyBoy · · Score: 1

      For future reference, ask for a view with the 6 tables joined.

      Then you can have build the simple query you want and any issues with performance/maintenance will be in in the DBA hands.

      Unless you are playing with data-warehouse size data or are using a toy *cough*MySQL*cough* a view like this shouldn't be a problem.

      --
      The surprise isn't how often we make bad choices; the surprise is how seldom they defeat us.
    6. Re:Developers and SQL by Pfhreakaz0id · · Score: 1

      fine, but unless you are using a materlialized view (which is, in most cases, only for read), that doesn't address the fundamental problem of joining and reading/updating/deleting rows from six tables is slower (in most, but not all cases) than putting it in one.

    7. Re:Developers and SQL by ralphbecket · · Score: 2, Insightful

      Of course, your B-tree traversal code is going to understand issues of concurrency, replication, locking, optimisation, scalability, failure, error recovery, robustness in the face of change of the database layout, and be maintainable by everyone else who comes after you.

      Or maybe you could leave that to the DBMS which already understands these things.

    8. Re:Developers and SQL by ralphbecket · · Score: 2, Insightful

      Normalisation is a tool to protect the integrity of the database. It is concerned with the logical model of the data. It should have nothing to do with the underlying physical representation of the data (ask a competent DBA). Denormalisation is a dangerous hack.

    9. Re:Developers and SQL by Pfhreakaz0id · · Score: 1

      Are you sitting here telling me that splitting data that is usually read/updated together (particularly read) from one table into six isn't much slower. Denormalization is an everyday tool used to get acceptable performance from a database. There are other ways a competent dba can ensure the integrity of the data (for instance, you can force all data updates to be done through stored procedures.. I've seen this done before).

      This is what I'm talking about... go ask slashdot's dev if there database is 3rd normal form. I would be shocked if it is.

    10. Re:Developers and SQL by GoofyBoy · · Score: 1

      >that doesn't address the fundamental problem of joining and reading/updating/deleting rows from six tables is slower (in most, but not all cases) than putting it in one.

      May I suggest you build your own persistency layer on the tier you have control over that does the inserting/updating/deleting? That way you just need to address the 6 tables once and never look at it again. I don't think you should have a problem with a 2-3(?) hour job.

      --
      The surprise isn't how often we make bad choices; the surprise is how seldom they defeat us.
    11. Re:Developers and SQL by Baki · · Score: 2, Informative

      Slashdot is not handling really important data. any sane DBA (I'm not a DBA but mainly a developer) of a DBMS of any importance will normalize, must normalize. A DBMS lives for many generations of application programs, you cannot tell in the future how the data will be read. What counts is that the data is logically structured with minimum chance for inconsistencies, and duplicate data (which is what denormalized essentially is) always leads to inconsistencies sooner or later, or at least to maintenance nightmares.

      You can speed things up by using materialized views or maybe derived tables (denormalized) for special (reporting) purposes.

    12. Re:Developers and SQL by Anonymous Coward · · Score: 0

      Nonsense, the length of the query has nothing to do with performance. I've actually tuned some of those query's and written some myself with the queries completing in sub-seconds. I'm a DBA supporting both MS SQL Server and Oracle.

    13. Re:Developers and SQL by Fulcrum+of+Evil · · Score: 1

      And the complexity of the query does. It also tends to track the length of the query. Since we don't have the query, the schema, or the datasize, that's all we have to go on.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    14. Re:Developers and SQL by TrueKonrads · · Score: 1

      From ease-of-use point of view, a mat view can have triggers or, in PostgreSQL case, rules that would take care about updating to all six tables. DBA is happy because data is consistent. Developer is happy since he can operate on one table and the speed issue is solved by addressing by PKEY that is auto-indexed anyway. C'mon, this isn't an assembly demo contest, speed sacrifice is acceptable as long as the data is safe.

      --
      Lone Gunmen crew.
    15. Re:Developers and SQL by killjoe · · Score: 1

      There are two main reasons people denormalize. One is that they are using artificial keys. It's become all too common to use increasing integers and guids. This leads to...

      Not carrying the keys to related tables. If there is a relation four tables deep (customers, invoices, lineitems for example) then the table at the end needs to carry all the keys of all the parent tables.

      I know many people will disagree with those points I found that it's the single biggest cause of umpteen table joins. Sure it takes a lot of room to carry all those keys, sure multi field primary keys are not in fashion anymore but in my opinion it's the only way.

      --
      evil is as evil does
    16. Re:Developers and SQL by PinkPanther · · Score: 1
      A developer who doesn't know the basics of the environment they are working in will blame the environment for misbehaviour before trying to understand the abuse they have invoked.

      I can, and have (to prove a point), take down a Very Beefy Database Server with a simple three-line SQL script. Does this mean that it's a database problem?

      The database engine's job is to take your query and retrieve the results as quickly as possible. However, if you tell it to run around the block to get next door in such a way that it has not choice but to follow your directions...shame on you. Relational guys can only pattern so much stupidity in their optimizations.

      --
      It's a simple matter of complex programming.
    17. Re:Developers and SQL by vadim_t · · Score: 1

      That leads to maintenance nightmares. I'm actually going in the reverse direction.

      Integer keys are wonderful. Product #5 is just that, product #5. If you want to find something about it, join to the products table.

      Sure, you can make a text product code, and have 'ENERGIZER_AA_BATTERY' instead of #5. That'll look good for a while. Until one day boss comes and tells you they messed up, and it actually should be 'AAA'. That's when you see the difference. With integer keys, the key is meaningless and eternal. You change 1 field in 1 table.

      With the text key, however, you now need to fix all references to this product everywhere, which is easily 50 tables on a large DB. If you're unlucky and can't have the DB propagate changes correctly, you now need to make sure to update every single table, and not forget any.

      But that's just the beginning, because obviously you have to do all this stuff inside a transaction. A transaction which in a database like MSSQL will create lots of locks that have excellent chances of bringing the whole DB to a screenching halt for whatever time it takes to do the update.

    18. Re:Developers and SQL by killjoe · · Score: 1

      "With the text key, however, you now need to fix all references to this product everywhere, which is easily 50 tables on a large DB."

      It depends on your database. On some databases the database takes care of all that for you. You change the master and the database changes all the child records. It's called "cascaded updates and deletes".

      Anyway...

      Relational theory says that each row must be uniquely identifable. People have hacked on the integer key to obey the letter of the theory while ignoring the spirit. I am not saying you should never use it, I am saying you should avoid it whenever possible (like NULLs).

      My second point is that all child tables must carry all the keys of all parent tables and that the primay key must be a multi field key. If you do that then your database becomes much easier to maintain.

      This is wrong...

      Table Invoices.
      CustomerID, InvoiceID.
      1,1
      1,2
      2,3
      2,4

      It should be like this
      CustomerID, InvoiceID
      1,1
      1,2
      2,1
      2,2

      Until you do that your database will be a nightmare to maintain

      --
      evil is as evil does
    19. Re:Developers and SQL by vadim_t · · Score: 1

      Yup, I know about cascaded updates. That doesn't make it being stop being a pain in the arse though, as it doesn't always work, and physical constraints get in the way. Now that you have a code that has some actual meaning for somebody, changing it becomes a pain. Disks are slow, searching millions of rows takes time, and unless you're lucky enough to use a smart database like postgresql you end up with tons of locks that grind things to a halt. Major pain if it happens often.

      Take an example from Unix, for example. You have an username, but what's stored on the disk is a number. If you find you want your account renamed, all the admin has to touch one line in /etc/passwd instead of searching every file on disk and correcting the username stored in it.

      IMO, serial numbers are nearly always the best identifier for almost everything. Say, clients, products, etc. Why would you want to force your users to come up with a primary key? If they need "Foobar Enterprises", then just provide a good search dialog and let them find that. Otherwise you end up with things like "FOOBARE" for a primary key, people get mixed up when they enter "FOOBARI" instead, etc.

      That's the best case, usually you'll end up with the database full of primary keys like 'ASDF' and 'KITTENS' because somebody didn't want to come up with something that made sense that day or they got annoyed when their choice was already taken and just typed something random to get it to work and be done with it. And if it doesn't make sense, why not just avoid it completely and let the database give it a number?

      Personally, I only make exceptions where there's a natural primary key.

      Your second example has maintenance problems, btw. It happens that people make an invoice for the wrong company. Sometimes because they messed up, sometimes because the company has multiple accounts for whatever reason. The first way it's trivial to move an invoice, the second it isn't.

    20. Re:Developers and SQL by NoOneInParticular · · Score: 1

      The point being that the DBMS might actually understand these issues, it does a piss-poor job at implementing them. Please give me concurrency, replication, locing, optimisation, scalability, failure, error recovery, and robustness primitives in the language instead of this chickenbone-waiving SQL type of code, and we'll see if we can actually avoid databases being the risee of the computing world by actually creating code that is portable, concurrent, reflective, scalable and robust.

    21. Re:Developers and SQL by NoOneInParticular · · Score: 1

      Why is a five-page SQL-query a problem? SQL is just a programming language and five pages of code is really not much. I usually churn out that much on a Saturday morning before breakfast. Why does 1 million lines of C run fast, while 5 pages of SQL is a complete hog?

    22. Re:Developers and SQL by Wire3117 · · Score: 1

      then make a few standard views and query on those. i'll bet your joins will be smaller.

  12. SQL fun by Anonymous Coward · · Score: 0

    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.

    That's kinda the point. Since data management is based on a complete theory, it's possible to write what you want *declaratively*, and let the DBMS figure out how to do it. You might be familiar with another declarative mini-language: arithmetic. For example, you write "1+2*foo", knowing that the computer will figure out how to compute that and (conceptually) replace it with a result value. SQL should be the same way (but of course they fucked it up and ends up being half-procedural, half-algebraic, guaranteeing that both the people who understand databases and the people who don't will be equally confused).

    The first few chapters of the book lay a foundation for the rest.

    Get a book on relational theory (I recommend Database In Depth, only 250 pages). Then you will have a *real* foundation.

    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?

    There's no "existing hypothetical" query optimizer. That doesn't even make sense. But the point is, this shouldn't be the first concern when formulating database queries. In theory, you should be able to write any equivalent query and have it run at the same speed, so start with that in mind and then optimize when needed.

    because he's not much interested in telling you what actually happens when a particular SQL statement is executed by a particular database

    No shit, if you're trying to understand data management, don't waste time thinking about PRODUCTS. Products come and go, data management theory won't change unless the universe does. Would you expect a book on calculus to talk about which form of integral is faster to computer? That comes AFTER you master the fundamentals.

    Start with a good book on theory, figure out how to translate simple, concise relational algebra queries into SQL (and wince), then figure out how to make them go faster. As an added bonus, you'll also understand object (network) and XML (hierarchical) models (such as they are), since they are just subsets of the relational model.

    1. Re:SQL fun by cruachan · · Score: 3, Interesting

      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

  13. A useful review - Thanks! by Anonymous Coward · · Score: 2, Informative

    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!

  14. SQL says what to do by booch · · 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.

    --
    Software sucks. Open Source sucks less.
    1. Re:SQL says what to do by Municipa · · Score: 1

      I don't think that is what he means. I think what he means is that it takes more thought about the code to understand exactly what it will do compared to the size of the code.

    2. Re:SQL says what to do by NoOneInParticular · · Score: 1

      And like with any declarative language, saying what to do is followed by wiggling chicken bones over the database cache and indexing at random places to actually get it do to what you said it should do within your lifetime. Or you can buy this book and figure out the subtleties of finding out how to say what you want with sufficient hints to how you want to get it done for the dumb machine not to choke on it. What was again the advantage of a declarative language?

    3. Re:SQL says what to do by booch · · Score: 1

      To me, that's generally a good thing. The alternative is to write a whole bunch of code to do one simple thing. One thing I remember about using Lisp is that the amount of concept per line was huge. Maybe you have to think about each line longer, but each line accomplishes a lot more. Generally, that trade-off is in favor of languages like Lisp -- at least for highly competent programmers.

      --
      Software sucks. Open Source sucks less.
    4. Re:SQL says what to do by Municipa · · Score: 1

      To me too, I like lisp. Another thing about SQL is that you sometimes have to be very aware of what is in your datasets or wierd things can happen, particularly with joins. Maybe better SQL programming practices elminate that?

    5. Re:SQL says what to do by syousef · · Score: 1

      The good old functional vs procedural language debate again.

      Let me say straight out that I hate functional languages. I think they're ass backwards. I prefer to actually tell the computer what to do than have it work out which way is best to do it, get it wrong at least 20% of the time, try to work out how to express the same thing slight differently to force different behaviour, and iterate this process till you have something somewhat acceptable.

      That said, SQL is very very powerful. The trouble I find though is that once you hit a brick wall you hit it hard. You suddenly end up with a query that's not going to do what you want without wrapping it in procedural code or rewriting it so that its original purpose is not at all clear from the code (thereby adding to a maintenance nightmare).

      Procedural languages (and I include object oriented languages since they're procedural languages "wrapped" with objects) are a much more natural way to express a list of steps to execute - which is generally how most people program. Also, we commit the cardinal sin of mixing procedural languages with functional and end up with such nonesense as the object relational mapping problem, then write entire frameworks to glue the two together.

      --
      These posts express my own personal views, not those of my employer
  15. Art is about creativity, not rote coding by Graboid · · Score: 5, Insightful

    Ahhh - but the best scientists are artists as well. (In fact, scientists and mathematicians often have more in common with artists than engineers).

    Sure, the mechanics of programming is rather dull and boring, but large scale system design often requires considerable creativity that is much better done by people not constrained by artificially perceived IT limitations.

    Coding J2EE isn't an art, but designing/building a massive neural net or complex, distributed game/simulation is. MySpace, Google, eBay, etc weren't concieved by 'classic' engineers, but, rather, by creative people who understood how technology can enable new paradigms.

    1. Re:Art is about creativity, not rote coding by gowen · · Score: 4, Funny

      Ah. You were doing so well, and then you said "paradigm".

      --
      Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
    2. Re:Art is about creativity, not rote coding by tthomas48 · · Score: 2, Insightful

      He used the word correctly. It is a real word, unlike "actionable". Just because a word has been overused in bizarre contexts, doesn't mean it can no longer be used in the correct one.

    3. Re:Art is about creativity, not rote coding by Anonymous Coward · · Score: 0

      I would completely agree with this. I would also go further and say that it does not just apply to software but also traditional engineering. For example some bridges go beyond the engineering involved in their construction and can be considered art. Others are just fairly dull pieces of engineering.

      If you cannot recognise the art that goes beyond just engineering then the world must be a very sad place indeed. While hidden from many, even database construction contains art. There are designs that inspire and those that merely do their job, this applies to all fields of endeavour.

      An inability to recognise art in your own field of expertise though, unfortunately the only option is pity because life without inspiration and occasional joy from your work must be a very dry existance.

    4. Re:Art is about creativity, not rote coding by Lord+Ender · · Score: 1

      Have you worked with someone who thinks programming is an "art?" They strive for cleverness, complexity, and originality. Those are the exact opposite of good engineering principles.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    5. Re:Art is about creativity, not rote coding by gowen · · Score: 1

      I know its a real word. I also know what it meant. Paradigm shifts are dramatic changes in the fundamental structure of our thought and understanding.

      Quantum theory is a new paradigm.
      "Let's sell books over the internet" is not a new paradigm.

      --
      Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
    6. Re:Art is about creativity, not rote coding by lpangelrob · · Score: 1
      Just bought the book, actually. (Granted, the company will pay for it.) I agree with what you said, but consider that it's called "Art of SQL" because the parallel (according to the intro/back of the book) is to Sun Tzu's "Art of War".

      Know thy enemy. :-)

    7. Re:Art is about creativity, not rote coding by DigitalAX · · Score: 1

      I'm sorry, but this is clearly the definition he was impying:

      paradigm ( P ) Pronunciation Key (pr-dm, -dm)
      n.
      One that serves as a pattern or model.

      He was referring to how it was setting a standard, not changing life or science drastically.

    8. Re:Art is about creativity, not rote coding by Anonymous Coward · · Score: 0
      They strive for cleverness, complexity, and originality. Those are the exact opposite of good engineering principles.

      This is a deep and fundamental oversimplification. Cleverness and originality are key to minimizing unnecessary complexity, and some complexity is often unavoidable. A cookbook might get you where you need to go 80% of the time, but the other 20% is the heart and soul of engineering.
  16. SQL Books by Municipa · · Score: 3, Insightful

    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. Re:SQL Books by Anonymous Coward · · Score: 0

      There are 10 diffrent calls to the database since most people program with a time constraint in mind, not efficency. I have been working on a project to convert an accsess database that took 3 years to develope (it was bandage ontop of bandage) to mysql and keep the same functionality within 2 weeks. This presents a lot of problems such as...

      We have a contact database with 100 diffrent elements per row (option for 2 of everything ect) and 5k rows. Now I have to reproduce the ability to do dropdown selection that is sorted by Last name, First name, First name of the secound person, Last name of the secound person (we have 2 of everything so there are 2 first/last names). What I should do is dump it all to an array and sort it from there however the easy way to do it is dump the database 4 times each time doing an ORDERBY `first_name_1` ect for each option. Time saved programing about an hour. Time added to make the page load... 5-10 secounds. Which one the customer is happy about? The latter since I get it done in 2 weeks instead of 3.

  17. Opening line by skiflyer · · Score: 1

    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?

  18. Sounds interesting, but ... by tomhudson · · Score: 1

    ... 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.

  19. Spoken like a hacker, rather than a pro by PCM2 · · Score: 4, Insightful
    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.

    --
    Breakfast served all day!
    1. Re:Spoken like a hacker, rather than a pro by Anonymous Coward · · Score: 0

      You pissed you ain't getting the respect (and pussy) deserved by a "real" "professional" "DBA"?

    2. Re:Spoken like a hacker, rather than a pro by PCM2 · · Score: 1

      Now there's a funny image. Touche!

      --
      Breakfast served all day!
  20. This is an excellent book by tcopeland · · Score: 2, 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 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 I'll consider it a job well done.

  21. bookpool by stoolpigeon · · Score: 4, Informative
    --
    It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    1. Re:bookpool by MagicM · · Score: 1

      overstock has it cheaper than bookpool.

    2. Re:bookpool by znaps · · Score: 1

      buy.com has it cheaper than overstock.

    3. Re:bookpool by Pink+Tinkletini · · Score: 1

      I bought it at Barnes & Noble cheaper than buy.com.

    4. Re:bookpool by Jackmn · · Score: 1

      Wait, so B&N is cheaper than buy.com which is cheaper than OverStock which is cheaper than BookPool which is cheaper than Amazon which is cheaper than B&N?

      Recursion error?

  22. Re:SELECT * FROM first_post; by Anonymous Coward · · Score: 5, Funny

    +---------+
    | You     |
    +---------+
    | Fail It |
    +---------+
    1 row in set (0.08 sec)

  23. Re:SELECT * FROM first_post; by Anonymous Coward · · Score: 0

    damn... I always read GOLD when I have no mod points... mod parent up!!! Funny++

  24. sql vs. procedural by JCOTTON · · Score: 2, Interesting
    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

    1. Re:sql vs. procedural by Anonymous Coward · · Score: 0

      select distinct

    2. Re:sql vs. procedural by cruachan · · Score: 3, Interesting

      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 :-)

    3. Re:sql vs. procedural by Anonymous Coward · · Score: 0

      "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 figure."

      perfectly legitimate reasons for not normilizing.

      "Anyway, this being the case, I have found that SQL is poor in handling a non-normalized table/database."

      I found it to be very usefull, like for nonnormalized RDBS
      "(cant really call a non-normalized table as a database can we? (nuther troll))
      Yes you can. hell a plian text file can be a database.
      Not an RDBS, but that is a specific type of database.

      "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."

      You could have two people with the same name.

      " I would like a simple command - give me all names and all their data for the latest pay period - something like that."

      oh , see by procedural, you mean something with a lot of built in functions You can use.

      In this post you have used normilized incorrectly,seems to not understand when you would and wouldn't want to normalize, display complete ignorance of what a database is, as well as not understanding what a procederal language is, well done.

      I have never seen a more succinent post that display the much ignorance before.

  25. Theory not a dirty word by fm6 · · Score: 4, Insightful
    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 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.

  26. Re:SELECT * FROM first_post; by ZeroExistenZ · · Score: 1

    Wouldn't that rather be "SELECT TOP 1 FROM Posts WHERE sid=#06/06/07/194246#" ?

    --
    I think we can keep recursing like this until someone returns 1
  27. "Art of SQL" Cheapest a Buy.com by roblambert · · Score: 1

    You can get "Art of SQL" cheapest at Buy.com, see:


    Lowest Prices for 'Art of SQL'

  28. an art? by SekShunAte · · Score: 1

    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.

  29. Cheaper isn't everything by PCM2 · · Score: 5, Insightful

    In fact, if you have access to a local, independently-owned bookseller in your area, you should be buying your books there instead of online.

    Stacey's Books in San Francisco doesn't give me Amazon's 34 percent discount -- in fact, it gives me 10 percent -- but it is a wonderful resource and not one I'd like to see disappear.

    That's not hyperbole either. This year we've seen two classic, quality Bay Area bookstores close their doors: Cody's on Telegraph Avenue in Berkeley and A Clean, Well-Lighted Place for Books on Van Ness in San Francisco. These were not holes in the wall; they were spacious, carried a lot of stock and had served their communities well for years. (And believe me, the Bay Area in general buys a lot of books.)

    The reality is that the book market is changing. Superstores like Borders and Barnes and Noble have a lot to do with it, and so does Amazon. Another factor is the overall decline in book sales to the American public. People walk into Borders to buy DVDs of Friends and they pick up a paperback of Harry Potter at the same time. That's not the model I want my booksellers to be based around; I want to support local businesses that understand their communities and are dedicated to selling books.

    This is not to knock Amazon, or Borders or B&N for that matter; in communities where those are the only option, it's better to have someplace to buy books than no place at all. I still buy plenty of stuff at Amazon. But for books, I vote with my wallet.

    --
    Breakfast served all day!
    1. Re:Cheaper isn't everything by ars · · Score: 1
      In fact, if you have access to a local, independently-owned bookseller in your area, you should be buying your books there instead of online.

      Stacey's Books in San Francisco doesn't give me Amazon's 34 percent discount -- in fact, it gives me 10 percent -- but it is a wonderful resource and not one I'd like to see disappear.


      How about if people buy their books online, or where ever, and then send Stacey's Books some charity?

      Personally I don't see how that's different.

      The concept of buying someplace with a higher price to "support them" (as opposed to some other benefit, like service or selection) is no different then charity, so why not just skip the buying step and send the charity directly?
      --
      -Ariel
    2. Re:Cheaper isn't everything by PCM2 · · Score: 1
      The concept of buying someplace with a higher price to "support them" (as opposed to some other benefit, like service or selection) is no different then charity, so why not just skip the buying step and send the charity directly?

      Obviously the reason I want to support them is because of their service and selection, not to mention the fact that they have a physical presence that caters to my community, which chain superstores can't do. Please, you're not that stupid.

      --
      Breakfast served all day!
    3. Re:Cheaper isn't everything by ars · · Score: 1

      And you missed my point.

      For this particular book, why do you need to purchase from them? You know what the book is, so no service needed, and selection is also not aplicable.

      So how is buying this book from them (which is what you recomended) any different then charity?

      --
      -Ariel
    4. Re:Cheaper isn't everything by nschubach · · Score: 1, Insightful

      But the small chain stores could never carry the inventory to be able to go in and pick up any book in publish. Amazon allows this (even if they have to order it) It's not going to take any longer to get to you.

      As far as the "local shop" mentality. Why support a company that doesn't innovate? In the case of Amazon, it took very little to start them up. Even companies like UPS will offer dropship and warehousing services for the small business if they wanted to get into internet sales. If they choose not to go that route, I don't see why we as consumers should have to pay more for their lack of foresight/expansion.

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
    5. Re:Cheaper isn't everything by Anonymous Coward · · Score: 0

      I've established a bookstore in your area, please buy all of your books online and send me $1 charity for each purchase. You can rest assured that the $1 will go towards keeping this business local.

      My address is.....

    6. Re:Cheaper isn't everything by ShieldW0lf · · Score: 1

      For this particular book, why do you need to purchase from them? You know what the book is, so no service needed, and selection is also not aplicable.

      So how is buying this book from them (which is what you recomended) any different then charity?


      It's different because of the motivation. If you value the existance of a local marketplace because it offers you value, you support it with your patronage so it will continue to exist. Pretty simple equation.

      --
      -1 Uncomfortable Truth
    7. Re:Cheaper isn't everything by geekoid · · Score: 1

      You pay more for a book in exchange for having a bookstore is a value add for you?
      Just curious, but what service does it provide for you that a local library doesn't?

      Of course, I live in Oregon which has the most loved horrible book store on the planet, Powells.
      Lot's of used book at near or same as new books. Now with Snarky help!Gah.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    8. Re:Cheaper isn't everything by PCM2 · · Score: 2, Insightful
      You pay more for a book in exchange for having a bookstore is a value add for you? Just curious, but what service does it provide for you that a local library doesn't?

      Not a lot of O'Reilly books in most libraries. Computer books in general are often poor choices for libraries, because the technology changes so frequently. If you donate your computer books to a local library they will most likely sell them off for a couple bucks apiece at a book sale.

      If we're specifically talking about the bookstore I shop at (Stacey's), on the other hand, they have a whole section devoted to O'Reilly -- several shelves in fact -- in addition to books from all the other publishers, ranging from 800 page fluff-filed "Bibles" to serious college-level textbooks.

      But you raise another question, which is why buy books at all? And the answer to that is that, while I also have a library card, I regularly like to pay for my books, because I want a diverse variety of books to continue to exist and I want to encourage publishers to publish them.

      Also, even if you're talking about novels -- which you could argue are totally unnecessary purchases; you're only likely to read them once and they have no reference value -- they're also not really all that expensive. A trade paperback costs about $14 and it will probably take you at least 10-12 hours, total, to read. Compare that to a movie, which costs $10.50 in my city and averages an hour and a half. Even if you never go to the movies and just rent, and a movie rental costs $3, the book still gives you more bang for your buck.

      Plus, books make you smarter. Ask any writer. If you want to learn how to communicate better using the written word, you can take all the classes you want, but the absolute best thing to do is to read, read, read. Stephen King put it succinctly in his memoir, On Writing: "If you don't have time to read, you don't have time to write. Period."

      People really ought to read more, seriously. Any way they can get it. If they've got some money, they should be happy to pay for good books. It's a damn shame that most folks don't.

      --
      Breakfast served all day!
    9. Re:Cheaper isn't everything by colinrichardday · · Score: 1

      And what independent bookseller in Columbia, SC has the selection of a Barnes and Noble? Now in Denver, I might support The Tattered Cover, as it has a good selection.

    10. Re:Cheaper isn't everything by swillden · · Score: 2, Insightful

      In fact, if you have access to a local, independently-owned bookseller in your area, you should be buying your books there instead of online.

      Only if you also stop by and mention to the manager that you're only buying your books there so that they don't go out of business, and that most people who buy books won't do the same, and that you might not in the future.

      Businesses that require this sort of support in order to stay in business have a big problem: they're not viable businesses. What needs to happen is for them to figure out how to modify their approach to business so that they are viable. They need to provide additional value, or lower their prices and costs, or change their inventory or... something. If you believe that the business in question is one that actually can become competitive in the changing marketplace it's probably a good idea to spend a few extra dollars there to help them stay afloat while they figure out how to make the transition. If not, you're just wasting your money because they're not going to last anyway. Businesses don't survive long on the charity of their customers.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    11. Re:Cheaper isn't everything by epee1221 · · Score: 1

      There are two somewhat local bookstores I like to visit -- one used bookstore, and one cooperatively owned bookstore. Their inventory is a good match for what I'd be interested in buying, and I like the atmosphere in the stores themselves. Amazon is a nice substitute while I'm away at school, but there's more to these bookstores than the books themselves.

      But the small chain stores could never carry the inventory to be able to go in and pick up any book in publish.
      Frankly, I don't much care that the used bookstore doesn't carry everything under the sun. When I'm looking for variety, I don't mind reading something old or foreign. (The availability of out-of-print material is something of a novelty -- it can be interesting but is rarely of value.)
      As for the other bookstore, they actually will take special orders, and they have even done overseas orders.

      As far as the "local shop" mentality. Why support a company that doesn't innovate?
      Because in many markets, innovation is not necessary.

      If they choose not to go that route, I don't see why we as consumers should have to pay more for their lack of foresight/expansion.
      I can't say I feel like I'm paying any extra by buying at these shops. At one, I get a 10% discount, plus a share of the profits. At the other, prices are down from the cover price by over 50%.

      --
      "The use-mention distinction" is not "enforced here."
    12. Re:Cheaper isn't everything by syousef · · Score: 1

      That's all very nice if you have the money to spare. If you don't the choice becomes whether to buy the book at the faceless megastore or support your local bookshop. I love books and don't want to see them disappear but I'm not about to put my local bookstore on my list of charities - unless they can provide something the megastore can't I'll have to support the megastore.

      Of course I much prefer my books online, in a format that's no encumbered by DRM. I don't care if the book has no ISBN, so long as it's from a credible source. The entire publishing industry doesn't much support the author. I liken it to RIAA/MPAA.

      --
      These posts express my own personal views, not those of my employer
    13. Re:Cheaper isn't everything by PCM2 · · Score: 1
      Businesses that require this sort of support in order to stay in business have a big problem: they're not viable businesses.

      Bullshit. The only reason Amazon is able to offer 34 percent discount on new books is because their business model presupposes nationwide sales. Those economies of scale make lower prices possible but that business model also by necessity excludes any kind of customization for a given market. As in my market. As in me. Amazon tries to "recommend" all kinds of bullshit to me all the time but I'll take a book review from a Stacey's employee any day.


      On a slightly different topic, it's a little scary to me how many people on Slashdot advocate low price as the ultimate best arbiter of why they buy something. I sincerely hope all of you are in your early 20s -- because if you're not, and you've been burned by companies as many times as those of us who are a little older than our 20s have been -- then that doesn't bode too well for world economics in general.

      --
      Breakfast served all day!
    14. Re:Cheaper isn't everything by swillden · · Score: 2, Insightful

      Bullshit. The only reason Amazon is able to offer 34 percent discount on new books is because their business model presupposes nationwide sales.

      Irrelevant. If the store can only stay in business if customers decide to make a sacrifice, buying from the store even though that's not their best choice (considering overall value), the store will not stay in business and you're just wasting your money.

      On a slightly different topic, it's a little scary to me how many people on Slashdot advocate low price as the ultimate best arbiter of why they buy something.

      Who says price is the only consideration? Not me. In fact, if you reread the post you responded to, I said that businesses that need this kind of charity need to change *something* so they can attract more business and no longer rely on charity, and lower prices was only one of the suggestions I offered.

      That said, for many kinds of purchases, low price is my only selection critierion.

      I sincerely hope all of you are in your early 20s

      Check my slashdot bio.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    15. Re:Cheaper isn't everything by PCM2 · · Score: 1
      Irrelevant. If the store can only stay in business if customers decide to make a sacrifice, buying from the store even though that's not their best choice (considering overall value), the store will not stay in business and you're just wasting your money.

      And who's talking about sacrifices? Not me.

      You keep saying "but it's not the lowest price, but it's not the lowest price." And I keep saying "but the lowest price doesn't offer the best value, but the lowest price doesn't offer the best value." And then you say "but if it's not the lowest price then the customer makes a sacrifice." Yes, they do. They sacrifice the lower price for something else. How blind do you have to be not to see this? I am baffled, totally baffled.

      --
      Breakfast served all day!
    16. Re:Cheaper isn't everything by swillden · · Score: 1

      You keep saying "but it's not the lowest price, but it's not the lowest price." And I keep saying "but the lowest price doesn't offer the best value, but the lowest price doesn't offer the best value." And then you say "but if it's not the lowest price then the customer makes a sacrifice."

      Umm, you need to reread the part of my post that you quoted, particularly where it said "considering overall value". I never said price was the only consideration.

      They sacrifice the lower price for something else. How blind do you have to be not to see this? I am baffled, totally baffled.

      I can tell you're baffled. This is really quite simple, so let me try again:

      If you're making a conscious decision to patronize a particular store in order that it will stay in business, not because that store is offering you better value on that purchase, then you're just making a non-deductible charitable donation to a for-profit business.

      Your best decision is to buy from the store that best meets your needs. Chances are, that will sometimes be the local store and other times be Amazon.com or whatever. Choosing on principle to pay a higher price when you get no additional value for that price is foolish, even if you think that you might get additional value for the higher price on some potential future purchase. If you think that, make the future purchase at the higher price when the time comes. If the store can't stay in business unless you make both purchases there, then their business is doomed eventually, anyway.

      I've spent quite a bit of time thinking about this issue in the context of a different sort of store. I'm a SCUBA diver, and this exact debate has been raging in diving circles for many years now, with the volume turned up, because the retail markups on SCUBA gear are as high as 200%, and good stores are very valuable resources. The reason markups are so high is that dive shops sell very low volumes, and gear sales are (or have been) the bulk of their income. That leaves the door wide open for high-volume on-line retailers to massively underprice their brick and mortar competitors... and they do. It's not uncommon to find gear for sale on-line for significantly less than half of what you'll buy it in a local shop. On the other hand, an experienced dive shop owner who knows gear, knows locations and knows diving is a hugely valuable resource, especially for new divers. And even if you somehow know everything and never need any advice, the fact that local shops provide air fills is really valuable, but there's no way that the shops can possibly make a living filling and/or renting tanks.

      So as a diver, there's a lot of value in having a local shop around, but that doesn't change the fact that it's hard to pay $900 for a BCD I can buy on-line for $350.

      My conclusion is that the dive shops need to find another way to make money, because selling gear at such high markups isn't a viable business in the long run. And, in fact, most shops that are still around have largely made the transition, extracting their profits more from training and dive travel services and less from gear sales (though they don't seem to have decided to actually lower their prices).

      In general, businesses must learn to co-exist with Internet retailers, because the net isn't going away. Adapt or die; depending on charity from your customers won't work in the long run.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    17. Re:Cheaper isn't everything by aevans · · Score: 1

      Movies make you smarter too, just ask any actor. Can I have your email address? I would like to send you an advertisement for my herbal supplement, it will make you *ahem* smarter.

    18. Re:Cheaper isn't everything by aevans · · Score: 1

      Even better, the big booksellers like Amazon and Borders are actually good for the marketplace. They are an *increase* in competition, not a decrease. They force the price down that the evil big publishing cartel used to control because small booksellers (and hence buyers) had no leverage over.

  30. procedural programming by jbgreer · · Score: 4, Insightful

    "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

    --
    The Norton Anthology of English Literature, 4th Ed., Vol 2
  31. Sun Tzu! by fm6 · · Score: 1

    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. 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.

    1. Re:Sun Tzu! by kpharmer · · Score: 1

      It's important that in a book entitled "The Art of SQL" they followed the organizational structure of "The Art of War".

      Well, it really isn't at all important should it be a surprise.

      And The Art of War faddish? The book is over 2500 years old, influenced Emperor Napoleon, General Patton, BH Liddell Hart (who in turn influenced the creation of the WWII German military strategies), General McArthur, etc, and has sold well to non-military types for at least 20 years. I think the world could use a few more books that survive the test of time 1/10th as well.

    2. Re:Sun Tzu! by fm6 · · Score: 1

      Sure, TAoW is an important book. Unfortunately, it's the kind of book that will always be popular with dweebs who don't know the difference between true insight and just knowing a lot of epigrams. There are a lot of good books that get abused this way, and every few years the focus among the terminally shallow shifts from one book to the other. Which fits a reasonable definition of "fad", no matter how good the book is.

    3. Re:Sun Tzu! by lfourrier · · Score: 1

      Disclaimer : I'm probably biased. I shared many clients with Stéphane since 1998, I live less than a mile from him, and I always have a lot of pleasure to discuss with him when we meet in the train, BUT :
      - He clearly is educated.
      - The plan to follow the art of war is a few years old, and was explained to me a long time before the co-author was chosen. And remember that choosing a formal constraint can give a boost in creativity in matters of writing. Having decided of some not-too-much-incoherent plan frees the mind about important matters.
      Now, as an aside, I can garantee you that the Art of War is not faddish now where we live. Perhaps in some parts of the US. Not here, not now.

  32. Difference by Brownstar · · Score: 1

    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.

  33. the sample chapter is promising by sqlgeek · · Score: 2, Informative

    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.

  34. The Art of Computer Programming by dazey · · Score: 1

    References to Knuth's volumes titled "The Art of Computer Programming" http://www-cs-faculty.stanford.edu/~uno/taocp.html are sprinkled liberally throughout many, many papers in computer science, especially wrt algorithms. It's more of an abstract art, as opposed to the "physical" arts like paintings and sculptures. You can't ignore the engineering aspect of it, yes, but if you manage to engineer a system well AND do so with simplicity, elegence, and creativity ... well, that distinguishes the true progessional.

  35. Re:MOD UP if the new Slashdot HTML sucks by Anonymous Coward · · Score: 0

    You'd think that they'd have tested that sort of thing.

    Especially when it would have only taken one or two people a couple of work days at most to really go over it all and make sure that there were no glaring errors in the layout.

    Working at Slashdot must be the most relazing experience in the world, what with all that not working that they do.

  36. WTF is a "theoraticians" by mcmonkey · · Score: 2, Interesting
    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.

  37. interesting by sgt+scrub · · Score: 1

    I have to recommend a good under $20.us book to go with it.

    http://www.powells.com/biblio?isbn=0071359532

    --
    Having to work for a living is the root of all evil.
  38. easy by BitterAndDrunk · · Score: 1

    Bills of Materials lend themselves perfectly well to tree structures.

    --
    You better watch out, there may be dogs about . . .
  39. Aristotle by Anonymous Coward · · Score: 0

    According to Aristotle, arts have techniques, while sciences have laws.

    1. Re:Aristotle by Lord+Ender · · Score: 1

      What did Aristotle say about engineering disciplines?

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
  40. select distinct by mveloso · · Score: 1



    Actually, they don't, in the sense that there is no one single built-in command to handle this case. Just like in SQL, you (or someone else) has to write the function that performs a 'select distinct' equivalent.

    Unless you're using a targeted-product (one built specifically for your data needs), nothing you do will be handled natively in any language. You can build this functionality by using correct SQL or writing the appropriate functions in a procedural language.

    And why don't you consider 'select distinct' a built-in function?

    1. Re:select distinct by JCOTTON · · Score: 1
      And why don't you consider 'select distinct' a built-in function?

      Oh, but select distinct is definitely a built in function. However, it is not the function that I am looking for. Because if you select distinct on whole rows, you will get every row. I want a built in function that will select distinct on a few columns, but return the entire row.

  41. Trees are graphs; M2M is a general graph structure by jabbo · · Score: 1

    Storing things as adjacency lists (which, obviously, is an M2M table where the node properties live in their own normalized table) tends to be faster in the long run for all but the largest and most active trees.

    Nested sets are cool, and I've implemented them (in MySQL 4.1 no less), but at the end of the day, traversing a graph happens far more often and more usefully.

    This seems to be where the CS majors separate from the rest of the crowd. Point out that they ought to know how to do this unless they failed 2nd year ;-)

    --
    Remember that what's inside of you doesn't matter because nobody can see it.
  42. Re:MOD UP if the new Slashdot HTML sucks by Anonymous Coward · · Score: 0

    the old HTML was much much better.

    The HTML hasn't changed at all. It's the CSS that's changed.

  43. CTEs by BitterAndDrunk · · Score: 1

    Are we talking parent-child hierarchy tables? If so, Oracle's had statements to take care of that for a long time, since 1998 or so. Perhaps not ANSI standard, but they get the job done.

    --
    You better watch out, there may be dogs about . . .
    1. Re:CTEs by Osty · · Score: 2, Informative

      Are we talking parent-child hierarchy tables? If so, Oracle's had statements to take care of that for a long time, since 1998 or so. Perhaps not ANSI standard, but they get the job done.

      No, I'm talking about Common Table Expressions (okay, so I was slightly wrong about implementation of CTEs -- apparently other products have implemented the standard, but DB2 and SQL Server 2005 are the only "Big Boy" engines with them). CTEs aren't so much about implementing a hierarchy as they are about doing recursive actions quickly and efficiently. Walking a parent-child hierarchy is just an example of a recursive problem that's easily solved with a CTE, but CTEs don't dictate how you should store your relationship information.

      For what it's worth, it's possible to write recursive algorithms in just about any SQL implementation (convert your recursion to iteration, and it's not so bad), but the win with using CTEs is that it's still a set operation. Doing the loop yourself means you're losing SQL's set-based power. I did a little comparison on a naive parent-child implementation, doing two things: return the path to parent from a given node, and return the subtree of a given node. I implemented each algorithm in SQL 2000's T-SQL without CTEs and in SQL 2005 with CTEs. The CTE implementation was approximately 10 times faster than the by-hand iteration solution.

    2. Re:CTEs by BitterAndDrunk · · Score: 2, Informative

      TY for the info.
      FWIW, the parent-child solve in Oracle is set based. CONNECT BY I think is the syntax, but it's been almost 7 years since I was working BOM hierarchies that utilized it heavily.

      --
      You better watch out, there may be dogs about . . .
    3. Re:CTEs by Anonymous Coward · · Score: 0

      For those who don't like Reading The Fucking Manual, here's an excerpt from Oracle 9.0 (old enough, I guess):

      subquery_factoring_clause

      The subquery_factoring_clause (WITH query_name) lets you assign names to subquery blocks. You can then reference the subquery block multiple places in the query by specifying the query name. Oracle optimizes the query by treating the query name as either an inline view or as a temporary table.

      You can specify this clause in any top-level SELECT statement and in most types of subqueries. The query name is visible to all subsequent subqueries (except the subquery that defines the query name itself) and to the main query.

    4. Re:CTEs by Johnno74 · · Score: 2, Informative

      The very cool thing about CTEs in SQL 2005 is you CAN reference the query name inside the query that defines the subquery. It references itself; it automatically recurses when it is executed.

      Like this: (shamelessly ripped from http://www.yafla.com/papers/sqlhierarchies/sqlhier archies.htm)

      WITH CTE_Example (EmployeeID, FullName, BossID, Depth)
      AS
      (
              SELECT EmployeeID, FullName, BossID, 0 AS Depth
              FROM Employees WHERE EmployeeID = @boss_id
              UNION ALL
              SELECT Employees.EmployeeID, Employees.FullName, Employees.BossID, CTE_Example.Depth + 1 AS Depth FROM Employees
              JOIN CTE_Example ON Employees.BossID = CTE_Example.EmployeeID
      )

      SELECT * FROM CTE_Example

  44. The food reference, I'll bite by cerelib · · Score: 1, Interesting

    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.

  45. By the sound of it by Anonymous Coward · · Score: 0

    you.

  46. Save $7.65! by Anonymous Coward · · Score: 0

    Save yourself $7.65 by buying the book here: The Art of SQL. And if you use the "secret" A9.com discount, you can save an extra 1.57%!

  47. There's a bigger CRAP by dbdweeb · · Score: 2, Insightful

    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.

    1. Re:There's a bigger CRAP by Tablizer · · Score: 1

      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.

      Lots of case statements is often a sign that one is misusing SQL such that some parts should be done in application code. I am not saying that all CASE statements are bad in queries, but it is a yellow alert. A few can be powerful, but lots can be a maintenence nightmare.

    2. Re:There's a bigger CRAP by dbdweeb · · Score: 1

      In this particular case it was a one time deal and the key values were guaranteed not to change. Another technique would be to add a column to the table called sortval or something, then change the ORDER BY clause to ORDER BY sortval, keyval, blah, blah, blah

  48. Re:MOD UP if the new Slashdot HTML sucks by Anonymous Coward · · Score: 0

    Can I pick the old CSS style?

  49. Shame the book doesn't... by Anonymous Coward · · Score: 0

    ... cover JoSQL (http://josql.sourceforge.net), in fact it's single focus on RDBMS's is a shame, since SQL is used in many places other than RDBMS's.

  50. It's DBA problem by Anonymous Coward · · Score: 0

    You want to get theorrectical, here it is:

    SQL is declartive - the user simply "declares" what s/he wants. It's up to DBMS/DBA to figure out how to execute the tasks. If the result is too slow, IT IS DBA (and DBMS) PROBLEM.

  51. The cooking analogy by Pentomino · · Score: 1

    So it's like Alton Brown's "I'm Just Here for the Data"?

  52. Why? by patio11 · · Score: 1
    In my entire life, I have never received any service from a book seller other than selling books and directions to the shelf where the book I wanted was at. Amazon does both of things with an efficiency that asymptotically approaches perfection. Yeah yeah, rah rah little guy and all that, but for a new book for pleasure reading I go straight to Amazon first. The only time I go to the bookstore is when I'm in the mood to get out of the house for a bit -- our local mall has a bookstore which is located right next to obscenely overpriced but quite tasty iced cocoa.

    Yeah, I can understand the nostalgia for a bookseller who "knows what I want" and "understands the community". But, reality check, Amazon recommendations churned out from a little AI magic and some freakishly large database just utterly destroy anything a minimum-wage retail staffer with no knowledge of my tastes can hope to accomplish. "Well what do you like?" "Hmm, I don't know, a bit of everything. I read a lot of fantasy or Tom Clancy.". "Well, in that case, can I recommend you go to our fantasy or Tom Clancy shelves?" (Gee thanks, why didn't I think of that.) Amazon *knows* that there is a British alternate history of the Napoleonic Wars fought with dragons that is right up my alley (incidentally: it starts with His Majesty's Dragon, and I'm *loving* it).

    Community involvement... well... I'm all for teaching kids to read and exposing them to the classics. And I support libraries, churches, and schools that do. But bookstores are, well, poorly suited to the task. I also, how do I put this gently, sort of fail to be a member of the community the bookstore is representing on a regular basis? I live in Japan at the moment -- the most community-oriented mom&pop bookstore around here can't possibly be community-oriented and still be Patio11-oriented. If I got a job in San Fransisco, I'd be pretty bloody out of place as the Catholic Republican and some of my reading selections might not make a San Fransisco bookseller abundantly happy. Then there's just the practical limits of bookseller expertise and shelf-space: excuse me, Mr. Mom&Pop Bookseller, can you recommend me a good book for a twenty-something set in modern China written in English which is *nothing like* Shanghai Baby? Thats what I was looking for the last time I bought a birthday gift from Amazon, and you can browse yourself a dozen choices in less time than it takes to get to the head of the line to speak to the clerk.

  53. So is safari.orelly.com evil also? by iconnor · · Score: 1

    It is hard to know what is the right thing to do. Although, I want to support my local stores and community, I also don't want to use up trees. So is buying online and reading online better than buying a mass published book from a local store?

  54. Not always true by Anonymous Coward · · Score: 0

    You can tell the DBMS HOW to do it, IF you write your queries correctly.

    Too many people write their queries 'top down'. In order to specify how the query will execute you need to right your queries 'right to left'.

    WTF? Attend:

    SELECT *
    FROM TableA
    INNER JOIN TableB
    ON TableA.PK = TableB.FK
    WHERE TableA.Field1 = "A"
    AND TableB.Field2 = "B"

    as opposed to

    SELECT *
    FROM (SELECT * FROM TableA WHERE Field1 = "A") AS A
    INNER JOIN (SELECT * FROM TableB WHERE Field2 = "B") AS B
    ON A.PK = B.FK

    This, in effect, ENSURES that the 'WHERE' clauses will be executed first, and the join operation will be performed on minimal sets (post filtering).

    NB: Filtering is faster than joining, do the filtering first.

  55. mod error informative: about 20 years wrong by Fubari · · Score: 1

    "umm... dude? SQL has been around since the mid 50's." ?

    Why did the parent post rate informative?

    "A guy at ibm," you say :-)

    The theory came out in 1970, so you're off by 15 years.
    Off 20 years for an actual implementation (mid 70's).
    Off 25 years for commercial product (79).
              http://en.wikipedia.org/wiki/SQL#History

    ----

    "anchronistic and irreperably flawed." ?

    "Duuuude!" :-)
    What would you replace it with?

    By ANY measure, relational databases are a RESOUNDING
    success. They're as much a part of the computer world
    as operating systems, networking, and compilers.

  56. saw this book right next to... by lateralus_1024 · · Score: 1

    ...The Art of SQL Injection. tough choice.

    --
    If you think /. comments are bad, check out Digg.
  57. I wonder if this book by Anonymous Coward · · Score: 0

    will get a sequel

  58. Re:MOD UP if the new Slashdot HTML sucks by Anonymous Coward · · Score: 0

    Wouldn't it be nice if you could choose which CSS style you wanted in your preferences.

  59. Peer Pressure. by smcdow · · Score: 1

    ... 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.

    This developer doesn't. I prefer flat files, especially for storing large amounts of raw binary data.

    But nearly every time I have a review for a design that uses flat files for persistent storage, the DB wonks have conniption fits and insist that I use a DB.

    I think it's the DB enthusiasts that have the problem.

    --
    In the course of every project, it will become necessary to shoot the scientists and begin production.
  60. Re:Trees are graphs; M2M is a general graph struct by Chazmyrr · · Score: 1

    You have it backwards. Traversing a graph is an iterative operation. RDBMSs are designed for set operations. Nested sets are much faster for reading than an adjacency list but are also much slower for updating. In a large, highly active tree, nested sets may not meet performance constraints.

    To put things in perspective, I have a nested set tree with a ragged hierarchy with 50k nodes. Node level security is in place. A worst case insert currently requires 1.5 seconds. Selecting the descendants of a node and filtering against the ACLs requires .5 seconds for any node in the database. Selecting the descendants iteratively is faster only in the special case of few descendants and takes anywhere from .25 seconds to 20 seconds.

    The tree is read more often than it is updated so the nested set meets my performance goals in all current cases while adjacency lists do not meet my goals in some cases.