Querying Microsoft SQL Server

Training Kit (Exam 70-461): Querying Microsoft SQL Server 2012 by Itzik Ben-Gan, Dejan Sarka, and Rom Talmage
$43.79 at Amazon ($69.99 cover price)

I’ve been using SQL Server at work for a couple of years now, but I’m not a DBA; I mostly just run simple queries to test that data was loaded correctly by our ETL process. This year I’m leading a small group of coworkers who want to become more proficient in SQL Server, so we’re studying for the MCSA in SQL Server 2012. This certification requires passing exams in three areas; the material on the first exam, 70-461, is the subject of this book.

The book starts out with the obligatory disclaimers: real-world experience is required to pass the exam, and you should already understand how to write a query and run it, even if you don’t know the fine details. Naturally, you’ll need a copy of SQL Server 2012 (a trial copy is fine). The book comes with a CD containing practice tests, an PDF of the text, and a copy of the scripts (which can also be downloaded from O’Reilly). Finally, the book includes a coupon code for 15% off any Microsoft Certified Professional Program exam; the tests normally run $150, so that’s probably a $22.50 savings if you plan to take the exam.

Before getting into the code, we start off with Chapter 1: Foundations of Querying, where we learn a little about set theory and the difference between standard SQL and Microsoft’s T-SQL. (Incidentally, if you’re trying to do a search for how to do something in SQL Server and want to avoid getting results from other flavors of SQL, searching in T-SQL is a good way to do it.) Chapter two brings in some code: the select statement. At this point, you’ll need to have installed the TSQL2012 database (which, as mentioned, is a free download). With the basics down, chapters three through seven discuss various ways of querying and managing the data, including filtering, sorting, combining, and grouping. In chapter eight, we start actually creating our own tables; chapters eight through eleven cover the various data structures (tables, views, functions, etc) that we can create and how to insert, update, and delete the data in them. After that we move into more advanced topics, such as error handling, dynamic SQL, and performance.

My study group has been going through the book at a rate of one chapter per week and found it quite readable. My only real complaint has been that the test questions at the end of the chapter sometimes ask about something that wasn’t actually discussed, but this is a minor irritant. A few chapters are fairly dense, but most of the writing flows easily, and we found a few tidbits that should be helpful at work.

The practice test gives you several options First is study mode, in which you choose how many questions you want and can look at the answers whenever you like; this mode is not timed. In certification mode, you have a 44 questions to complete; this mode is timed (with two hours given) and you cannot stop the timer. In custom mode you can set it up however you like, including specifying the objectives to be included. When looking at the explanation (either during a study mode test or afterward) you also get a reference to the appropriate chapter of the book and relevant pages on MSDN. After completing a test, you’ll see your overall score as well as your sub-score on each of the exam objectives, and can generate a learning plan (that is, links to MSDN pages on what you missed). All of the questions I’ve seen so far are multiple choice, however, which I’ve heard is not true of the actual exam.

I haven’t taken the exam yet (I expect to do so in October or November, though scheduling it is inconvenient) so I can’t say for sure how well the book has prepared me for it, but I feel like I’ve learned a lot about T-SQL by reading it. I’ll update this review after the test, but for now I rate this book a definite buy.

Disclosure: I received a free review copy of this book.

Google+

HTML5 Graphing and Data Visualization Cookbook

HTML5 Graphing and Data Visualization Cookbook by Ben Fhala
$44.99 at Amazon

Although I’ve been using HTML5 for a few years now, I haven’t yet done much with the Canvas, the new drawing element. Having started, it reminds me of nothing so much as moving the turtle around in the old Logo programming language.

In HTML5 Graphing and Data Visualization Cookbook, we start out by learning to create basic shapes in Canvas, with the gimmick of creating various national flags. This takes up only the first two chapters of the book, as it is presumed that the reader is already comfortable with HTML and JavaScript; the remaining eight chapters involve creating and using maps, graphs, and charts, both simple and animated. Towards the end of the book, we actually get into using the Google Maps API to overlay our data onto a world map.

In each chapter, we start by typing in some new code and run it; after that, the book discusses what the code is doing. I liked the format because you see results right away – each code segment is relatively short – and then after seeing what happens, you see how it works. I also liked the little mathematical explanations and programming asides that pop up here and there. The chapter organization also makes it easy to jump to the section of the book you’re interested in, so I think this will make a good reference.

There were two things that irritated me about this book. The first was that the spacing in code is a little odd, with extra spaces where I wouldn’t expect to see them and no space where I do expect one. This doesn’t affect how the code works, but it’s a little distracting. The book is also written in a fairly informal manner, complete with smileys; at times I felt like I was reading blog posts rather than a professional programming book. That said, neither of those really takes away from the usability of the book, and are more a matter of personal preference than anything else. For the topic this book covers, I haven’t seen anything better.

Disclosure: I received a free review copy of this book.

Google+

The Healthy Programmer

The Healthy Programmer by Joe Kutner
$27.05 at Amazon

Everybody knows the stereotype of the programmer: hunched over a desk, working too many hours, drinking too much caffeine. By and large, the stereotype is true, and we have the back, wrist, and eye aches to prove it.

The Healthy Programmer is a quick read, with a companion iPhone app, that aims to help programmers take better care of ourselves. As with almost all health and wellness books, there’s no revolutionary new information here – much of the contents I’ve seen before, in one form or another – but the author does a good job of relating the content to its intended audience. Each chapter (Preventing Back Pain, Refactoring Fitness, etc) starts out with a story that introduces the topic, dips briefly into the scientific details (there’s a long bibliography at the back of the book), then lays out practical steps to take (such as simple exercises to add to your daily routine) and a goal (such as getting an eye exam or taking a yoga class). The free app is essentially a checklist for doing your recommended items (take 10k steps per day, get five minutes of movement every hour) but the author also recommends various other sites you can use if you prefer something more elaborate.

I just finished the book this afternoon and haven’t worked through all the exercises or met most of the goals yet, but it already inspired me to download a pedometer and start keeping track of how much I walk (a little under 4k steps per day, it turns out) and to make the effort to fidget more while working at my desk. I’ve never been much for exercise, but after reading this book I’m feeling at least a little bit motivated. Five stars for a quick, interesting, and inspiring read.

Disclosure: I received a free review copy of this book.

Google+

Getting Started with Raspberry Pi

Getting Started with Raspberry Pi by Matt Richardson and Shawn Wallace
$12.18 at Amazon ($8.69 Kindle)

The Raspberry Pi is a hot new computer system, approximately the size of a credit card and costing $25-$35 (plus a $5 markup depending on where you buy one – my preferred source is Sparkfun Electronics in Boulder). The Pi is a system on a chip that includes a 700Mhz processor and separate GPU, plus up to half a gig of RAM; the model B comes with several USB ports, an ethernet port, and HDMI output. They can be used from everything to learning to program under Linux to streaming HD video to your television.

With so many possibilities, though, it can be hard to know where to start, especially if you’re not accustomed to using Linux – which is why I picked up a copy of Getting Started with Raspberry Pi. This is a fairly short book that doesn’t go into any topic in depth, but it gives you a good starting point and links to more information. It’s a quick way of getting going and figuring out what you want to do with your Raspberry Pi.

Chapter one covers obtaining a Pi and getting it set up. The technical information is more detailed than the actual setup instructions, but extra setup help is available in the first appendix. What I like about this chapter is that it has nice diagrams showing were everything is on the Pi.

Chapter two is an introduction to Linux, the free operating system you’ll use on the Pi. While there are several distributions that will work, the officially recommended official distribution is a variant of Debian called Raspbian. This chapter will get you going with using the command line and maneuvering through the Linux filesystem.

In chapter three, we start our first programming language: Python! Raspbian has both Python 2.7 and Python 3 included, so you’re ready to go with whichever version you prefer. Python is a high-level language with the design philosophy that there should be one obvious way to do things (as opposed to Perl’s “more than one way to do it” approach). This chapter has you writing a simple program and ends with a list of resources for learning the language, such as the online Learn Python the Hard Way book. Once you’ve learned the basics, chapter four moves into doing animation and multimedia using the Pygame framework.

One of the reasons for creating the Raspberry Pi was for kids to be able to learn to program, without the worry of damage to the household computer. Accordingly, the Pi comes with MIT’s Scratch, which is a graphical programming language that can be used to learn the basics of programming without actually having to code; you can easily drag commands around to make simple animations and games. Chapter five covers Scratch.

Prior to the release of the Pi, the Arduino was the go-to component for embedded systems hobbyists. Many of the components used with the Arduino, as well as the Arduino itself, can be used with the Raspberry Pi. Chapters six through eight have you doing physical things with your Pi, like turning LEDs (or lamps) on and off and reading in input from buttons. (The Pi can handle a number of digital inputs, appendix C covers converting analog inputs) Chapter nine takes that a step farther, using a webcam with the Pi (which, after all, uses a chip meant for cell phones, which generally have cameras). The Pi can even handle simple face detection.

Finally, chapter ten discusses creating internet-connected projects, such as using the Pi as a web server.

I found this book to be a nice, quick read; typos were minimal and it gives a good overview of the different things you can do with the Pi. So far it’s inspired me to start learning Python, which seems like a nice little scripting language, and I’m considering eventually turning my Pi into a DVR. What will you do with yours?

Google+

CLR via C#

CLR via C# by Jeffrey Richter
$34.48 at Amazon

While I did notice when Microsoft introduced .NET and the CLR (Common Language Runtime), it wasn’t until 2011 that I first used them, when I had the opportunity to learn C#. At the time, I needed a working knowledge of the language – enough to do some minor debugging – but I never really dived into the details. Over the last few months I’ve found myself getting more involved with updating C# and VB.NET code, leading to a desire to go more in-depth into C# and the framework. Given the reviews, I’ve had my eye on CLR via C# for a while, so the new edition pushed it to the top of my reading list.

In the past I haven’t been very impressed with the level of editing at Microsoft Press (I absolutely detested their book on SQL Server 2008) but they’ve definitely improved lately; CLR via C# is a pleasure to read. As the title would imply, the book covers the various features of the Common Language Runtime using C# sample code (and mentioning other languages when the designers of C# chose not to implement something that the runtime supports). The author also throws in his own opinions on various design decisions, which I find interesting.

I have two problems with most programming books. The first is that they tend to be boring to read. The second is that they tend to be written at one of two levels: either they assume you’re an absolute beginner and work up from Hello World (here’s what assignment is, here’s what a loop is, here are the ways to write one) or they assume that you’re already completely fluent in one language and just want a dictionary to convert that to another language. In the first case, anyone who isn’t a beginner is bored out of his or her mind (bringing us back to point one); in the second case, the book is hard to use unless you’re already familiar with the concepts and the language the author assumes you’re coming from. For myself, I learned to program around 1988 and programmed on and off until 2004, when I became a math teacher; when I started writing code again, what I needed is something that would explain concepts I wasn’t familiar with (partial classes, delegates, etc) without first requiring me to wade through the programming equivalent of “See spot run”.

CLR via C# is one of very few books I’ve seen that manages to strike that kind of balance. While it throws in a lot of the basics – value types vs reference types, for example – they’re used in the context of explaining how something is implemented in the CLR, so it still keeps my interest. The text is nicely cross-referenced, which has the helpful side effect of reminding you (if you’re reading the book straight through as I chose to do) whether or not it’s referring to something you’ve already covered, as well as either reinforcing already-learned material or previewing more advanced structures.

When I started the book I got bogged down a bit in the first section, which covers how the assemblies are put together, but I felt it really picked up from there. For me it clarified a few concepts that I’ve seen referenced but never formally learned. As a matter of personal preference I also liked that while the code was in the CLR language I use most, the book also mentioned areas where the differences between the languages affect code interacting between them. Overall, highly recommended.

Disclosure: I received a free review copy of this book.

Google+

The Nine

The Nine by Jeffrey Toobin
$10.88 at Amazon

Many of the opinions the Supreme Court issues are dry and technical, deciding obscure points in the law; simple cases, after all, can be decided by the lower courts according to past decisions, and the justices of the Supreme Court choose what cases they will take. Then there are the cases that draw the eyes of the country, such as Bush v Gore and Citizens United vs Federal Election Commission (usually known simply as Citizens United). When the court agreed to hear lawsuits challenging the constitutionality of the Affordable Care Act, it seemed as if everyone in the country had an opinion. In the end, though, it comes down to the opinions of nine justices.

How do they decide? In theory, a judge should only interpret the law, and rule as the law is set out – but even the justices of the Supreme Court don’t agree as to how the Constitution should be interpreted. For some, everything should be decided by considering what was meant by the founders as they wrote the document; anything the founders wouldn’t have had an opinion on is beyond the scope of the Constitution. Others believe that we should follow what the Constitution literally says, rather than trying to read the minds of the founders. Some, like Stephen Breyer, are strong advocates of state decisis – that the court should tend to follow their previous opinions. Others, like Clarence Thomas, prefer to ignore previous decisions they feel were wrongly decided. Many of the controversial cases heard by the Roberts court have been decided on a 5-4 vote; the final decision on whether a law should stand often comes down to the judicial philosophy of the swing voter (with Sandra O’Conner gone, this is usually Anthony Kennedy).

So what leads a justice to these decisions? In interviews with the justices and more than 75 of their clerks, Jeffrey Toobin learns about their personalities, their relationships with each other, and how they approach the work of the court. As in Toobin’s later book The Oath, this is often illustrated through their approach to various cases – Bush v Gore, Planned Parenthood v Casey, Ledbetter v Goodyear. While Toobin sometimes interjects his opinion – in particular, he obviously feels that the justices embarrassed themselves in Bush v Gore – he allows each of the justices to express themselves in their own words, and indeed has admiring words for each of them. (Published in 2007, the book covers the eleven justices who served under Bush.)

Since getting this book, I’ve barely been able to put it down. Recommended for anyone interested in the workings of the court.

Google+

The Lego Builder’s Guide

The Unofficial Lego Builder’s Guide 2nd Edition by Allan Bedford
$16.18 at Amazon ($9.18 Kindle)

It’s been forever (well over a decade) since I played with Legos, but my wife and I recently decided to take up playing with them again; we just finished building the Lego Creator Volkswagon T1 Camper Van. We’re planning to build a few more of the sets (I have my eye on the Tower Bridge) and then start designing our own models.

The Unofficial Lego Builder’s Guide is about doing just that: learning to design and build your own creations. The first chapter was actually the most helpful to me: putting together the Camper Van I often had trouble describing exactly what I was looking for, and this section puts names to them so that I can more easily describe them. Chapter two goes into building techniques; a lot of this is stuff that should be fairly obvious (even as a little kid, it didn’t take long for me to figure out that I needed to overlap bricks so that my walls wouldn’t fall over!) but this chapter was worth it for me just for the explanation of how to use the brick separator, which is something that I definitely did not have but could have used twenty years ago!

Chapter three covers building to minifig scale, which is what I’m planning to do; it gives the basic conversions for scaling things down. Chapter four is miniland scale, where you actually build the people as well as everything else, and chapter five covers building bigger bricks (and then building with those bricks). Chapter six goes in the opposite direction, with a discussion of how to build models that are much smaller than real life, suggesting rather than including various elements. Since I’m only interested in minifig scale, chapters 4-6 weren’t that useful to me but it’s still interesting to see what people are doing.

Chapter seven is where we really get into recreating real-world objects with Legos, as we walk through the design process for building a model of the Sphinx. Chapter eight, for the artsy people, covers building mosaics. Chapter nine is essentially a continuation of chapter seven, and we work our way through designing a model of the space shuttle (with a parts list and much discussion).

Want to show off what you’ve build? Chapter ten covers several ways to create instructions for your models so that you can share them with others. The book also includes appendixes showing a good selection of the available Lego pieces and instructions on using the (downloadable) design grids for planning out your models.

Overall, I enjoyed reading the book and will probably put together the example models once I pick up some more Legos (they do use common pieces, so if you’ve been collecting for a while you’re likely to have most of what you need already; my old Legos are in storage so I’m starting from scratch). I wouldn’t say this is something you’ll find yourself referring to again and again, but for someone who’s interested in getting into the hobby (or just starting to move from prebuilt sets and simple houses to more detailed designs) it’s a good way to get started.

Disclosure: I received a free review copy of this book.

Google+

The Lego Adventure Book

The Lego Adventure Book by Megan Rothrock (No Starch Press)
$16.47 from Amazon ($9.99 Kindle)

When I was a kid, I liked legos but didn’t have a lot of them. One problem I had was that with my limited selection, I had a hard time figuring out what to build other than a house. (Ok, I wasn’t a particularly imaginative kid, either!) Of course, back then you couldn’t hop on the internet for ideas, but there weren’t books of lego models you could buy either.

The Lego Adventure Book is part instruction manual, part tip book, part idea book. For a few of the models, there are step by step instructions that show all of the pieces you’ll need, both all together at the start of the instructions and at each step. For others, you don’t get a parts list; you just have a series of pictures of the model in various stages of construction. Still others have no instructions whatsoever, just one or more pictures of the finished model.

The author is a former set designer for Lego, and I like the look of a lot of the models in the book. The book itself is large and full color; I read it (there’s a plot of sorts, with one of the characters flying around to see different designs) in an evening. My only real complaint is that there’s no parts listing with the official brick names; it would be nice if there was a companion website that made it easy to find the pieces you need for each model (in terms of either sets that have them, or their names on Lego’s pick a brick site). I know that I don’t have the right parts to actually build any of the models, so for now, it serves simply as an idea book and an interesting read.

Disclosure: I received a free review copy of this book from No Starch Press.

Google+

The 4-Hour Chef

The 4-Hour Chef by Timothy Ferris
$21 from Amazon ($5 Kindle)

I think Tim Ferris is a bit of a nut. But he’s an entertaining nut.

Having read The Four-Hour Workweek and The Four-Hour Body, I find that, alas, I have become neither rich nor superhuman; however, I enjoyed both books and took away a few useful tidbits, so I was happy to preorder The Four-Hour Chef as soon as it was available on Amazon’s site. I’ve been wanting to learn to cook for years, but cookbooks tend to drive me crazy. (Season to taste? Cook until done? I’m a computer programmer – give me precision!)

As with Tim’s other books, this one is all over the place; while it’s nominally about cooking, it’s really about ways to learn with cooking as the thing you happen to be learning. Lots of other things get thrown in: how to memorize a deck of cards, using a gun to make sure your luggage arrives safely, the best generator to have on hand for emergencies – pretty much whatever catches Tim’s interest. I find these sidebars amusing and think they improve the book, but I can see them being pretty annoying to someone who just wants to know about cooking.

The book is divided into five sections, plus an appendix. Section one discusses Tim’s ideas about learning, with stories about how he worked them out and used them (this includes losing weight – with an excerpt from The Four-Hour Body – and learning languages. Section two is the actual “learn to cook” part of the book; there are 17 “lessons”,to be completed over two months (cooking twice a week). In theory, cooking all the different dishes in this section will take about four hours total to fit the theme of the book. I’ll update the review once I’ve tried them all out to see how well that works, but from my read-through it’s looking good; Tim chose the recipes to be very difficult to screw up, which is exactly what I want. (The first night’s dinner, for example, contains eight ingredients if you count salt and pepper as separate ingredients, and requires a knife, cutting board, and dutch oven (plus maybe a can opener). Total hands-on time is listed at five minutes. In other words: exactly what you want to see when you don’t have a lot of confidence in your cooking skills!

Section three is the outdoors part of the book: it starts with the more or less conventional topics (choosing a gun, cooking venison) and then goes on to more unusual topics that I’m pretty sure I won’t be actually putting into practice (how to catch, kill, and cook a pigeon or squirrel). I’ve never killed my own food, so the parts about how to kill chickens and lobster could come in handy, and there’s a lesson on how to butcher a chicken. For the most part, though, I read this section for entertainment only rather than any desire to actually follow the recipes!

Section four is science. This section gives you a brief description of various terms (gels, emulsification, foams, etc) along with recipes demonstrating each thing. Unfortunately, some of them are a bit impractical for the home cook (I would love to try the 30-second ice cream recipe, for example, but I have no idea where I would even get liquid nitrogen!) I liked that the descriptions were informative without being overly technical (I have a background in science, I don’t have a degree in chemistry!) and while some of the equipment IS more elaborate in this section, most of it isn’t particularly esoteric; I have a reasonably stocked kitchen and I think buying an immersion blender and vacuum sealer would let me do most of them.

Section five is for cooking at a professional level. Here you have many “classic” recipes (french omelet, roast chicken) that any chef should know, followed by more unusual dishes meant to teach you various advanced principles such as form mimicking, texture manipulation, and themes. (I think my favorite recipe in this section, prior to trying any, is the edible dirt centerpiece – it really does look like flowers in dirt!) The section ends with the most ridiculous dish I’ve ever seen: the ingredient list spans give pages, and the total hands-on time is listed at 10-20 hours. That bit of absurdity seems the perfect way to finish out the book.

Except, of course, there’s more. The appendix seems to be whatever random stuff relating to food and learning Tim decided to throw in at the end: a recipe from every country in 140 characters or less, instructions on making free shots in basketball and tying knots, maps of where to eat in NYC and San Francisco. There are also additional materials online.

Overall impression? While I haven’t tried any of the recipes yet, the instructions make them look like things I can actually do; I’ll come back and update the review once I’ve worked through section two in the kitchen. I would have preferred to drop section three (or move it to its own book) in favor of an extended section two; I’m more interesting in the step-by-step introduction than in things I’m unlikely to ever use like acorn pancakes and illegal fishing equipment. That’s my only real complaint, though, and the book is certainly big enough (over 600 pages) to squeeze everything in. Until I get a chance to actually try out the recipes, I rate the book 4.5 stars based on sheer entertainment value.

Google+

Think Like a Programmer

Think Like a Programmer by V. Anton Spraul
$20.39 from Amazon

While I was working on my PhD in computer science, part of my job as a TA was to run the computer lab. I never cared for Java, but I learned enough of it to be able to help the undergraduates when they got stuck working on their homework assignments.

What struck me is that often the undergrads know more Java than I did; their problem was that they didn’t understand how to solve problems. Once I walked them through the process of designing a solution, then they could write the program. When I interviewed at Microsoft, the interviewer said the same thing: that many of the people he had talked to were not able to even answer the first interview question (which required figuring out a solution to a problem and then coding it).

As such, it’s no surprise that I was happy to see this book, with its promise of helping people understand how to solve problems rather than simply how to write code. The first chapter immediately dives in to solving some logic puzzles; while these aren’t computer related (and some are classic problems that everyone knows) they get the point across that programming is about solving problems. The actual language is secondary; what’s important is being able to break the problem down to the relevant information and figure out a way to solve it. Once you have an approach that allows you to tackle the problem, then you can figure out how to do each individual step.

Chapter two switches to solving problems using C++, rather than generic logic puzzles, and then we’re off and running. We follow that with one chapter each on solving problems using arrays, pointers and dynamic memory, classes, recursion, and code reuse. Finally we have a chapter about working to your strengths as a programmer to find solutions efficiently.

For the most part, I enjoyed the book. There are a few places where it seems that the author made a change to a problem or assumption and then didn’t fix later text that referred to the original version; for example, in chapter 5 the default constructor for a student object initializes grade to 0 and studentID to -1, but the following text refers to a possible error due to grade being initialized to zero. Except for a problem in chapter two where relevant information is introduced in the solution rather than the problem description, though, these don’t detract too much from the reading.

At the end of each chapter is a list of simply-described programming problems that require you to thoroughly explore the concept covered in that chapter. Working through them all should take some time, but will probably be worth it; even as a working programmer, I’m tempted to go through all of them just to get a better handle on C++, which I rarely use.

The book assumes that the reader understands how to write a program with C++, but everything except the absolute basics has a review at the start of the relevant chapter. I think this would be a very good text to use for a freshman course on programming, assuming you can find one these days that still uses C++ rather than Java! (Although for the most part, the concepts apply to any language, so you could use it with Java anyway.) Having read this, a novice programmer should be much better equipped to break down a problem and get to work, rather than staring at the description wondering where to start. Recommended.

Disclosure: I received a free review copy of this book.

Google+