Slashdot Mirror


SQL Fundamentals

Slashdot's own Robo takes a look at SQL Fundamentals, writing "This beginner book takes a traditional look at the ever-popular Structured Query Language. Never bothered to learn SQL? Here's your chance. SQL Fundamentals, by John Patrick, takes a 834-page beginners look at the application of SQL to Access and Oracle. Read more for SQL Fundamentals' strengths, weaknesses and everything in-between." SQL Fundamentals author John Patrick pages 800 publisher Pearson Education rating 7 reviewer Rob ("robo") Oostendorp ISBN 0130669474 summary Truly a beginner friendly book for anyone needing a crash course in the basics of SQL; of limited but real use to those who already are familiar with SQL.

This beginner book takes a traditional look at the ever-popular Structured Query Language. Never bothered to learn SQL? Here's your chance. SQL Fundamentals, by John Patrick, takes the first layer of SQL in Access and Oracle [robo, I find this a confusing phrase, not sure how best to recast, but somehow] and sums it up in this 834-page manual. Read more for SQL Fundamental's strengths, weaknesses and everything in-between.

The Basics SQL Fundamentals discusses the practical realities of extracting information from a database. Patrick shows the reader how to use SQL in both Oracle and Access. The book starts with a brief overview of the roots of SQL and relational databases; after this introduction, the book covers select statements and the basics of a query. Each chapter builds on the next, and the book follows a simple progression, adding complexity as it goes along.

This book is a very easy read -- it flows much better than a textbook, yet still conveys the information it promises. However, it's definitely for newcomers to SQL. So, if you have any experience in SQL this would not be the best choice. (Chapter 1 explains the concepts of a cell, row, column, and table, which might be enough to let you decide if this book is at the right level for you.) Throughout the book, the author relies on applying each newly introduced concept to a single relational database example. This hypothetical database (a table of employees trying to calculate their meal credits) makes the book feel consistent, and helps eliminate confusion about where the example information comes from, but it's also limiting for readers who want a broader range of examples.

One of the greatest strengths of this book is its wealth of code examples and accompanying tables. In contrast to many other manuals, this book illustrates queries along with their effects on the tables. Other SQL books (ones I consider going up to "layer 2" SQL) have many example queries, but some of them fail to show any sort of results from their example tables. Also, much of the code in SQL Fundamentals is well documented, with footnotes explaining any changes that occurred.

Caution: Beginner Book The book is called SQL Fundamentals. However, in this case, the fundamentals are only as they apply to the Oracle and Access databases. It mentions the existence of other distributions at the beginning of the book: "Oracle, Access, DB2, MS SQL, Informix, SQL Windows, Sybase, SAS sql procedure, FoxPro, dBase, Tandem SQL, MySQL, SQLBase, Cold Fusion, SAP, Business Objects, ODBC, Ingres, Ocelot SQL, OsloData, PostgreSQL, Rapid SQL, XDB, SQL/DS, Mini SQL, Empress, Interbase, Progress, Supra, SQL Report Writer, Paradox, Delphi, VAX SQL, Essbase, Beagle SQL, GNU SQL Server, Just Logic/SQL, PrimeBase, Altera SQL Server, DataScope, and PowerBuilder." However, Patrick never speaks of them again; perhaps he should re-title this book SQL Fundamentals: Applied to Oracle and Access? Readers considering this book should keep this in mind. The book explains things well, but the book's overall logic is geared toward those using one of those databases, and the examples are relevant only in that context.

I primarily use MySQL and Progress, so a book explaining SQL fundamentals applied to Access and Oracle isn't going to help me unless I specifically take on projects which use these particular databases. Also, The book often goes into unneeded repetition of subjects: for instance, the first 150 pages are all about select statements. I've never seen so many select statements picking apart one table. I personally think it would benefit from being trimmed down, and leaving further study to the reader.

The Plug I would recommend this book to a newcomer to SQL. It covers the fundamentals just like it claims. After finishing this book, you will have a grasp on things ranging from the most basic select statements to unions, self joins, & cross-joins.

Something to consider might be what SQL database you will be working with. If you'll be working with either Oracle or Access this book will be helpful. If not, I suggest looking at things like Managing Using MySQL by O'Reilly.

Finally, from the text comes this concise answer to the question "Who Should Read This Book?"

Everyone with an interest in getting information from a database can read this book. It can be a first book about databases for people who are new to the subject. You do not need to be a computer programmer. The discussion begins at the beginning and it does not assume any prior knowledge about databases.

That seems like a fair summary; with the caveats already mentioned, I can recommend it for newcomers to SQL looking for a thorough but not patronizing introduction.

You can purchase SQL Fundamentals from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

26 of 215 comments (clear)

  1. Anyone Know? by laeraun2 · · Score: 3, Funny

    When the SQL to this book will be out? Har de har har har.

    --
    Error: Erection reset by beer.
  2. 834 pages?! by FyRE666 · · Score: 4, Insightful

    How big is the typeface? I mean, come on, it's not that big a language after all and you could easily fit the basics into 50 pages at most...

    1. Re:834 pages?! by micromoog · · Score: 5, Insightful
      Not having seen the book, I'm assuming much of it is dedicated to relational database concepts, explained via SQL. 834 pages is about right for an introduction. "Real" relational database design is a lot more complicated than most people (programmers particularly) realize.

      You could list and explain all of the syntax for C++ in just a few pages, but I wouldn't call you a C++ programmer after reading it.

    2. Re:834 pages?! by Abcd1234 · · Score: 3, Informative

      Just a note, the whole point of SQL is that it's a *declarative* language. The addition of an if-then-else construct completely breaks that model, producing something which is sort-of-but-not-quite procedural. ie, PL-SQL and similar variants. So, no, of course ANSI SQL doesn't have an if-then-else construct... it was never meant to!

    3. Re:834 pages?! by sphealey · · Score: 5, Insightful
      I'd say a good intro to ANSI-standard SQL could probably be done in 30 pages.
      SQL is like chess: 1 hour to learn. 8-12 hours to figure out how to play. 5000 hours to determine whether or not you actually understand it.

      Don't get me wrong - you can do useful work in SQL with 20-30 hours of practice. But if you think that SQL can be taught in 30 pages you do not understand it.

      sPh

    4. Re:834 pages?! by Usquebaugh · · Score: 3, Insightful

      Rubbish, chess is a very poor analogy for SQL.

      SQL is a tool to interrogate RDBMS. For most IT people it takes a couple of hours to get to grips with basics of select, update etc Joins, sub queries come next.

      You can do useful work in one hour of tuition. We have users using SQL after maybe two hours. 20-30 hours of practice, what the hell are you trying to do?

  3. The age old question... by Mr+Bill · · Score: 4, Interesting

    Do you pronounce it Sequel or S-Q-L???

    To me it is Postgres-Q-L and My-S-Q-L, but I think the Microsofties call it Microsoft Sequel Server...

    Maybe good for a /. poll!

  4. Learning Postgres Online by johnalex · · Score: 5, Informative

    If you need to expand your SQL to include PostgreSQL, try:

    PostgreSQL: Introduction and Concepts by Bruce Momjian

    Practical PostgreSQL, by Command Prompt, Inc. written by John Worsley and Joshua Drake of Command Prompt, Inc.

    Very practical definitions, examples, and procedures. I'm still scratching the surface of SQL, so I haven't found anything yet these sources can't handle.

    I've also found the Usenet Posgres groups useful.

    --
    JA
    http://www.johnalex.org/
  5. SQL by sql*kitten · · Score: 5, Insightful

    Something to consider might be what SQL database you will be working with. If you'll be working with either Oracle or Access this book will be helpful. If not, I suggest looking at things like Managing Using MySQL by O'Reilly.

    I would suggest not, because you will learn bad habits, and they will be hard to shake once you start working on a real database (Oracle, Sybase, SAP-DB, etc). I have seen MySQL programmers do massively inefficient (and stupid) things like retrieve a list of keys from one table, store them in an in-memory array, then loop through the array executing a select for each key in another table - because they didn't know about subselects. I've seen them put all sorts of redundant validation crap in the middle tier because they didn't know about constraints and triggers. I could go on and on...

    If you want to learn SQL, you first need a solid general foundation like this (I have an earlier edition) then later study the extensions that each vendor provides (Oracle PL/SQL, Sybase T-SQL, etc).

  6. MySQL gains more users thanks to Apple by ekrout · · Score: 3, Interesting

    With OS X came a bundling of MySQL, and CTOs (Chief Technology Officers) across the country thought to themselves that "Hey, if a big profitable company puts this package of OpenSource software into their flagship OS, it must be OK to use. Let's stop dishing out tens of thousands of dollars a year to Oracle and let's just use this free RDBMS implementation. (Sure, PostreSQL is a bit more weathered, but both are pretty nice considering their price).

    Wider acceptance of MySQL and its related products/technologies is a good thing, and books such as this are only a good thing in my mind.

    --

    If you celebrate Xmas, befriend me (538
    1. Re:MySQL gains more users thanks to Apple by sql*kitten · · Score: 3, Interesting

      Let's stop dishing out tens of thousands of dollars a year to Oracle and let's just use this free RDBMS implementation

      For the last few years, my career has largely been based on Oracle products, so I have as vested an interest as anyone (save maybe Uncle Larry) in seeing Oracle continue to be the #1 choice for corporate databases, but I've got to say, if you even can run your application on MySQL, you really shouldn't have bought Oracle in the first place, because you've completely wasted your money. Only buy a product like Oracle (or Sybase, DB2, etc) if you know that you need its capabilities. If your application doesn't need subselects, triggers, real transactions, etc, then you might as well use MySQL, or even CSV on the filesystem!

      Oh, and the R in RDBMS means "relational". Correct me if I'm wrong, but MySQL needs a plugin to even do foreign keys - you should really say just DBMS.

    2. Re:MySQL gains more users thanks to Apple by MattRog · · Score: 3, Interesting

      Having FK support does not make one a Relational DBMS. To those who are 'in the know' Oracle, MS SQL Server, even my beloved :) Sybase ASE etc are SQL-Based DBMS. SQL, to put it mildly, butchers most relational tenets and is not how Codd wanted it to work in the first place (enter IBM and SQL language).

      But in the least case MySQL supports relations (tables) so it has, to some degree, a relational background. FK support is required according to Codd, but virtually all DBMS also break some of his other rules as well, so it depends on how deviant a product must be before it is declared non-relational.

      --

      Thanks,
      --
      Matt
    3. Re:MySQL gains more users thanks to Apple by Frater+219 · · Score: 3, Interesting
      Oh, and the R in RDBMS means "relational". Correct me if I'm wrong, but MySQL needs a plugin to even do foreign keys - you should really say just DBMS.

      Actually, I've heard some folks take issue with the "M", on the grounds that a system that does not ensure relational integrity and transactional atomicity is not providing database management. Considering that many mySQL supporters bracket their support by saying that it is strongest for read-mostly databases (placing it in a category with LDAP's slapd), I would feel comfortable calling mySQL a "database daemon".

      (For my own reasons to choose PostgreSQL, and some links on the subject, see my Slashdot journal about my current work project.)

      For what it's worth, I'm glad that the mySQL folks have largely quit telling untruths about relational databases. A few years ago, they were saying in the mySQL documentation that foreign key constraints are for lazy programmers, and that anything that can be done with transactions can be done just as reliably with application code. (Imagine here Jamie Lee Curtis saying "Those are all mistakes, Otto. I looked them up.")

  7. Re:The age old question... by glwtta · · Score: 3, Informative

    It in fact is Postgres-Q-L and My-S-Q-L, but you use "sequel" to query both of those. I haven't seen anyone in a long time pronounce the language name S-Q-L, the names of the two products you mentioned are dictated by their respective developers, so it's a different matter. (incidentally, I'm as far from a Microsofty as it gets)

    --
    sic transit gloria mundi
  8. Re:The age old question... by beacher · · Score: 4, Funny

    It's Microsoft Squeeeeeal! Server (say it in your best deliverance voice )

    Todd

  9. Standard SQL? by K-Man · · Score: 4, Interesting
    I primarily use MySQL and Progress, so a book explaining SQL fundamentals applied to Access and Oracle isn't going to help me unless I specifically take on projects which use these particular databases.
    A statement like this needs a bit of support. Does the book use proprietary features of Oracle and Access? Most of the basic parts of SQL are the same on all platforms.

    --
    ---- "If we have to go on with these damned quantum jumps, then I'm sorry that I ever got involved" - Erwin Schrodinger
  10. Re:I don't get it! by binaryDigit · · Score: 3, Funny

    Actually for most /.ers you would get a nice fat result set back, however, you'd be forced to do an inner join with the "LikelyToBeInterestedInASlashdotReadingNerd" table and then you'd get no results.

  11. For More Advanced... by glenstar · · Score: 5, Informative
    For the more advanced, I *personally* would recommend Joe Celko's SQL for Smarties. Celko is a rather bizarre character, but there is no problem that he cannot solve using ANSI92 SQL. None.

    If you want to make the developers/DBAs/bosses in your company think you are an absolute god, get a copy of Celko's SQL Puzzles and Answers.

  12. Re:I don't get it! by r_j_prahad · · Score: 4, Funny

    Typical view error...

    CREATE VIEW girls AS SELECT * FROM slashdot WHERE sex = "F"

    ... returns an empty set iteself, so your subselect isn't going to do you any good, naturally.

  13. Re:The age old question... by sql*kitten · · Score: 5, Interesting

    It in fact is Postgres-Q-L and My-S-Q-L, but you use "sequel" to query both of those. I haven't seen anyone in a long time pronounce the language name S-Q-L, the names of the two products you mentioned are dictated by their respective developers, so it's a different matter. (incidentally, I'm as far from a Microsofty as it gets)

    It is properly S-Q-L because Sequel is something different (Structured English Query Language, an IBM project that never went anywhere). But the term "sequel" for SQL has come into common use, so it's the de facto pronounciation.

    Microsoft people just call the product "SQL Server" which IMHO is like calling Windows "Operating System" but it comes from the old days when Sybase and Microsoft cooperated (circa MSSQL 4-6/Sybase 10). Sybase's product was called "Sybase SQL Server", but people just call it "Sybase" (akin to calling Windows "Microsoft"). When they split, MS kept the rest of the name.

    You can easily spot a hardcore elite database guru by the fact that these people pronounce it "squirrel".

  14. Underestimating the complexity of SQL? by JohnDenver · · Score: 3, Insightful

    First of all, you do have a point. SQL isn't a big language with a lot of features, but if you had really spent a lot of time working with SQL, you would know that SQL is a language usually implemented with A LOT of nuances, and that many problems that are easy in procedural languages that take a lot of work with SQL.

    SQL is a powerful tool, but solving many problems with SQL can be very daunting at times, especially when you're dealing with vendor specific nuances.

    --
    "Communism is like having one [local] phone company " - Lenny Bruce
  15. Re:SQL by joshv · · Score: 3, Interesting

    I've seen them put all sorts of redundant validation crap in the middle tier because they didn't know about constraints and triggers. I could go on and on...

    Validation logic belongs in the middle tier. The storage tier is just that - storage. It shouldn't be smart, and it very definitely should do anything else than storing the data I tell it to store.

    Triggers, constraints - bah. All very vendor specific and they lead to application logic being strewn all over the tiers. Application Logic should be in the middle tier, period.

    -josh

  16. Re:The age old question... by mtDNA · · Score: 4, Funny


    Dear Slash-Dotters,

    I can't believe how clueless you guys are. Everybody knows it's Structured QUERy Language, or
    SQUERL, which is properly pronounced _SQUIRREL_.

    Sincerely,
    Steve

    --


    If you watch TV news, you know less about the world than if you just drank gin straight from the bottle.
  17. Re:SQL by NineNine · · Score: 5, Insightful

    hahahahaha... After 10 years of doing development, all of it with databases in the back end, I know people like you very well. People who don't understand databases don't know how to use them, and code all of the logic into the middle tier. Very typical. It leads to horrendous bloat, very poor performance, and occasionally, complete project collapse. In one case that I was involved in, the company closed because their project couldn't be done on time since they decided to listen to this "expert" who spouted off similar stuff like what you're saying. The project became an OOP mess that was impossible to debug and maintain. More importantly, performance was never acceptable, so the project and the company died.

    Databases, especially "grown up" ones like Oracle and DB2 are designed and optimized to do a hell of a lot more than data storage. If you want storage, use flat files. You should maybe, I dunno... pick up a book. You can write entire applications in nothing but PL/SQL that perform several times better than a similar C++ or Java app.

    In fact, so much development is done in the databases themselves, that Oracle has a certification just for that, called the Oracle Certified Application Developer. But alas, generally these days everyone is still running around screaming "middle tier! middle tier" while the real database gurus just sit back and laugh as projects implode.

  18. Re:SQL by pnatural · · Score: 4, Informative

    No, no, no... how do I say this? NO!

    The OP is completely correct: triggers and such are rubbish (except to enforce data integrity when the integral RDBMS mechanisms cannot). DBs are for storage, period. You claim that a DB is a great place to shoe horn logic, but that leads to problems.

    1. The bloat is in a functional-programming layer (SQL) instead of a procedural/OO layer. Given a choice between lotsa logic down in a DB and lotsa logic in my app, I'll take the logic in my app any day of the week. SQL does not promote code reuse, whereas most procedural and OO languages do promote it to some degree.

    2. The more code you put in a DB, the less portable your schema is -- and I'm not talking about platform portability, I'm talking about RDBMS portability. Nothing is worse than [IBM|MS|ORA] database lock-in.

    3. The poor performance you site may be common in your experience, but code in the middle layer(s) is not the cause of that: bad design and poor testing are the causes. Don't confuse correlation with causation.

    These points are backed with experience: I've been programming for 15 years, 7 years of that using databases heavily. The company I work for now has terabytes of data stored in the schemas I've developed for my apps, and no one has ever complained about maintenance or performance on one of my designs.

  19. Re:SQL by pnatural · · Score: 3, Insightful

    there's a middle ground between all or no logic in the "storage layer"

    of course. brilliant observation.

    tables thems selves contain application logic

    not my tables, and not any tables from the developers on my team.

    checking row types, etc.

    this isn't application logic, it's data integrity.

    "hey, you're using that querry quite a bit, how about we just compile it all up in the database for you and speed things up a bit, eh?".. bang, code reuse.

    sorry, that's not code reuse at all, not even close. give me a [stored proc|view|table] that i can inherit from or subclass, and that would be reuse.

    but those who spend 500,000$ for their RDBMS software package will keep it around for a tad.

    and one of the reasons that they'll "keep it around" is because they paid so damn much for it. why lock in an implementation decision for so long? it doesn't promote agility, nor does it promote flexibility. quite the opposite, it encourages poor SQL coding (i.e., vendor-specific features). it's called the "Golden Hammer" Anit-Pattern. look into it.

    most companies have terabytes of data stored in their schemas

    um, no. gigabytes, maybe, but most companies have databases in the terabyte range? i don't think so.

    you might find that if you take out all those i's and use lots of we's for the good of the compnay, you'll still get some credit

    funny, it sounds as if you haven't read _The Mythical Man-Month_, wherein Brooks asserts that the best software systems come from a single mind. if you're a professional software developer (it's hard to tell from your post), i strongly suggest you read it.

    as to credit, i'm not in it for that. rather, what motivates me is implementing solutions that help achieve the objectives of the company for which i work. see, i'm a stock holder as well as an employee, and i'm just as motivated by profit as the CEO.

    on another point, maybe should note that a great sense of ownership leads to pride in work and higher quality. (to be sure, there are pitfalls associated with too great a sense of ownership, but experienced developers know when and how to cut the cord, so to speak)