Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Wednesday, September 15, 2010

Three SQL books

In the main IIT library, there is a Computer Science section. It is woefully out of date and in general looks like something that you'd find in an abandoned bookstore, but as I was walking through it to sit down at a little table by the window with my new GRE prep book (and that's an entirely different story), I saw the SQL section.

I am uncommonly fond of SQL. Blame Dr. Nazli, who is a ridiculously good professor. http://www.ir.iit.edu/~nazli/

The three books are:
SQL Hacks by Cumming and Russel http://www.amazon.com/SQL-Hacks-Andrew-Cumming/dp/0596527993
SQL Cookbook by Molinaro (O'Reilly) http://www.amazon.com/Cookbook-Cookbooks-OReilly-Anthony-Molinaro/dp/0596009763
SQL Power by Hess http://www.amazon.com/SQL-Power-Comprehensive-Kenneth-Hess/dp/1598632124

I have not actually read these books. At most, I've skimmed them. Read the bits that looked interesting to me.

The Hess was published in 2007. That makes it old. It's kind of like a textbook, but a textbook which takes longer to say things than I think it should take to say them. In chapter 7 it goes into the basics of granting editing/admin privileges in databases, which Nazli didn't actually cover but which I picked up by running into it in use (and knowing that it MUST exist, right?)

SHOW GRANTS is so oldschool that it hurts. It's still nice to see it in print (not just on the internet.)

Nazli's teachings were wonderful, but limited; since we only ever worked with one database at a time, she only mentioned USE in passing, which (from my only slightly removed yet much more haughty viewpoint) I think is somewhat comical.

The longer and more complicated that queries get... the better. Well, not exactly. It's certainly better to get only the data out of your database that you want to get.
And queries are much better than doing it by hand, ha ha.

I guess it's the skill beyond the one that used to screw with me in middle school- translating long word problems into sensible, accurate algebraic equations that can be solved.

Oh, gods, CROSS JOIN. I'd forgotten about that one. In general, it's not useful unless you need ot do permutations. But sometimes you do, and I guess that's how you do it.

Batch data loading - possibly that is the cool part of databases. From what I understand, it's all about how to get the data from its current form- possibly its raw form- and load it into your database where you want it. Perl is your friend here. (I need to get better at Perl. I know just enough to write Hello World and recognize RSA encryption. Not the best skillset out there, but improving it is what sounds like fun to me.)

Chapter 8 goes on about different keywords as if they're new or something. I guess they might be. This would be a pretty ok textbook for an introductory class taught to non-CS majors. Or at a public school (hello, IIT snobbery). I can see why it's so cheap on Amazon.

Ch 9 is about Views. Maybe I should read that one; Nazli only went over it lightly, and I didn't ace it or anything. I mean... basic stuff, right? It's not like it's in C or something. VIEW generally makes something that's read only- great for when you're piping data to 1.0 web users. ...Yeah, Ruby is better. But the people I hang out with think that Ruby is better than EVERYTHING. Don't believe everything on the internet.

pg. 246 "PHP is my web language of choice." All well and good in 2007 but I think I have to stop reading this book now.

pg. 259 the author describes his first experience with regular expressions.

Appendix appendix how to install things that have had new versions since then and weren't too difficult anyway appendix appendix.

The Hacks book looks interesting. It's also copyright 2007, but it looks worth reading. It's not for noobs, and it's not a textbook. More like a level 2 mid-level book, with an index that lets you skip to what you want. (Did I mention that the index on the Hess was somewhat... awkward? In Ch. 6 there were a dozen lines in the index that read "objective" for some reason.)

I've been reading the Hacks book. It's pretty cool. Led to me reading this mini article on how to corrupt a database while it's running (so that you can then run tests on it). http://sqlblog.com/blogs/linchi_shea/archive/2007/08/29/how-to-corrupt-a-sql-server-2005-database.aspx

In ch. 6, there's a section on processing web server logs. I don't have any current need of it, but it looks fun.

Incidentally, I just now got my SQL Server running. Version 5.1.39, MySQL. I think I had installed it when I was taking that class with Nazli, but it never really worked out and I left it floating around my system unsetup. All better now. Although for some reason I'm getting some serious lag which I have yet to identify the causes of.

Oh, gods. Now it's time for me to look at the Cookbook. (The Hacks book looks neat, but I'm not currently trying to do anything which it covers- it has several specialized topics.)

The Cookbook is copyright 2006. That's horrifying. Hasn't Galvin bought any new books since 07? Perhaps not- the university cut out almost all TAs this semester to save on budgetary thingies. I wonder if the university will be surprised when fewer of the professors publish this semester, the average student grades go down (or suspiciously up), et cetera.

Skim index. First thought: cool, cool, skillbuilding, code snippets.
Second thought: what the hell is a pivot (in the contest of databses)?
Flip to page 349, where the topic is "finding knight values." I have never heard of a Knight Value.

Ahh. They're called "knight values" because, in order to get the "knight values" (your desired result set) you must navigate across the chessboard (database) like a knight does- i.e. kinda zigzag. It's a cute name for a complicated query.

pg 350 That is a fucking complicated query. I need to learn some kind of procedure for coming up with those on command, using nothing but a list of client demands, my own brain, and the database.

Generating Forecasts is another section heading. It sounded complicated but it turns out that, when it comes to shipping, it's not only the Thing To Do, but somewhat easy. ...go read the goddamn thing; I'm not retyping it. Easy doesn't mean short.

"Pivoting" is also known as transposing. Basically, turn rows into columns. (Sounds complicated.) I guess I DO know what that is. We never actually did it, though. Sounds like what we did with C in some lab once.

*complicated is a GOOD thing.

Pivoting. They use CASE and SUM here. It looks relatively easy, although you have to basically custom design it for every case. And what must it DO to your database design? Dear gods. Nazli stressed good dependencies, keys... pivoting is obviously a refactoring mechanism, but if you don't do as part of a larger plan, all of your dependencies will go shoot themselves.

Reading on, things get more complicated and yet strangely more intelligible...

Enough.