Kicking off with the most familiar type of database (relational) we start our journey with PostgreSQL.
Now having used MySQL (whee!) and Oracle (boo!) quite a lot in my day job(s), I consider myself to have a pretty good grounding in relational database magic. Although having said that, I’ve never actually used PostgreSQL, and have heard fanatical talk about how “amazing it is” when compared with similar DB’s, so I’m looking forward to enjoying some of that wonder for myself.
So to start, we’re left on our own to install the application (which is fine by me), and as the book mentions, we get more of the good stuff due to the space saved. Thanks to pacman (not the greedy yellow thing that’s s**t scared of ghosts) it’s all sorted in one command, done!
Day One
For first part we’re taken through some of the basics of relational DB’s, namely creating tables with relationships which we join across, adding indexes to improve performance etc – the usual stuff, that if you’ve been a developer for more than a week you should know by now!
It’s nice to have a some exercises to walk through but generally you’ve seen it all before, and it becomes a little tedious. Don’t get me wrong, I understand why it had to start like this (to give some context and a decent introduction to the 5% of readers not familiar with the material), but you just have to go through the motions and accept that the goodies will start soon. Sooner than I expected to be honest, I thought the whole PostgreSQL chapter was going to be (inevitably) a little slow, but I was definitely wrong there …
Day Two
Starting off with the usual aggregate functions (COUNT, SUM, MAX etc) you get that “been there, done that” feeling again, but before you know it you’re stumbling into new territory (for me at least).
Key areas that tweaked my interest were talk of distributed databases and the CAP theorem (Consistency vs Availability vs Partition Tolerant, of which you can only ever support two of the three), PL/PGSQL scripting (which initially gave me cold sweats when recalling Oracle’s own PL/SQL, but the knowledge of other scripting solutions, ala Python, Ruby, gave some welcome relief), and rules. I was impressed by rules in particular, reminiscent of metaprogramming or AOP for SQL, where you can essentially rewrite a user’s query to add a welcome twist – the example given in the text is insertion of a record into a view, although I can imagine countless other applications of this.
After day two I’m feeling like I’ve learned some interesting new things about PostgreSQL, which were well worth my time, …, but just wait until the craziness of day 3 …
Day Three
Here’s where things really get interesting! We start looking at many of the PostgreSQL contrib packages, allowing us to take the DB from the usual every-day querying tedium to the fringes of artificial intelligence!
Rather than sticking to basic equality or wildcard matches used for querying an actor’s name in a movie database we extend our schema to use various natural language processing libraries. This gives our humble set-up the ability to match ‘Broos Wils’ correctly as the star of the Die Hard films (many thanks on behalf of members of the SMS generation everywhere), most impressively matching based on how words “sound” using metaphones.
We finish up querying for movie recommendations based on a multidimensional hypercube (had to put that in ‘cos it makes me sound well clever). It basically works by comparing similarity of the various genres into which a movie falls (action, romance, comedy etc) – but check out the book, they explain it much more clearly!
Finishing Up!
To be honest I didn’t expect much from this chapter, nothing more than a recap over old knowledge anyway, filling the relational database corner for completeness and comparison. And yes it did start out a little like that, but it quickly moves into much meatier territory that sucks you in and teaches you things you had never considered possible in a RDBMS … or maybe that’s just my ignorance. Regardless, I’m impressed so far, and I am definitely looking forward to reading about databases I don’t already “know”!
Disclaimer
‘Seven Databases in Seven Weeks’ is still in production, and this preview was based upon the beta 2 release. The material is likely to change.
Check out the following links for more details :
http://pragprog.com/book/rwdata/seven-databases-in-seven-weeks