When you’re starting out as a programmer, you’re going to need to know SQL. I know from experience. Before I started my first programming job, I’d taken some algorithms and data structures classes, done an internship, and learned lots and lots of syntax for C#, the language I’d be using. Then I got to work, was meeting people, and the first question my boss asked was “How’s your SQL?”
Here’s the thing: Lots of software runs on servers and interacts with data. Lots of data lives in relational databases. The lingua franca for getting data out of relational databases in SQL. Even if you are not a data base administrator, you are going to want enough SQL to do a few things:
1. Figure out if the data are weird.
Data can do strange things. There will be nulls where someone promised you there wouldn’t be nulls. There will be that one contact who is in the database twice for some reason, and his cousin who is in the database four times. Your app needs to be able to handle these cases gracefully, which means you need to be able to find or simulate them.
2. Find basic test cases.
Maybe you are fixing a bug that only happens to contacts who have no fulfilled sales orders, exactly two canceled sales orders, and an international billing address. Maybe some code you wrote crashes, but only for these three users. Maybe your code calculates sales tax, but is wrong in Michigan, or wrong in this one zip code in Vermont. You must be able to examine the database to find these test cases and investigate them. (This is distinct from 1 in that, presumably, the data are not weird, but the code is wrong for some subset of correct data, and you need to find that subset.)
3. Make basic amendments to the data.
Maybe a new feature calls for us to track whether our customers are willing to receive advertisements via email. So we add a new bit field “accepts_email” in our database somewhere, and we need to set it to the default value. It’s a new field, so it will be ‘null’ everywhere, but, as Eric Lippert taught us, null is not false, so we need to set it to some default value. Even as a new developer, you should be comfortable making basic data updates like setting some field to ‘0’ or ‘1’ throughout a table.
So how to get there? There’s a course on EdX I recommend, which you can find here. The course is free, with the option of paying for a verified certificate of accomplishment, and is a fun introduction to SQL. (The course is on T-SQL, which is Microsoft’s flavor of SQL, but the different flavors of SQL are fairly similar, and you’re going to have to learn one of them first, so it may as well be that one.)
This course will give you enough SQL to get to work, and enough theory to reason intelligently about queries and the data sets they return. So go take it!
Till next week, happy learning,