HarvardX CS50 - Week 7

CS50 is a first year university course offered by Harvard University and more recently, Yale University, which dives into the basics of computer science, exploring algorithmic thinking and teaching students how to code in a variety of languages including Scratch, C, and Python, amongst others. In the last few weeks of the course, it offers a choice of three tracks - game, web, or mobile development that students can explore and create their final project which is encouraged to be something which is useful beyond the course.

The online course which is known as CS50x offers a stripped down experience of the real course. The assignments, known as problem sets (or psets), are marked against certain criteria and a number of test cases by an automated program. All of your coursework is pushed into individual branches of your own CS50 GitHub repository. I've copied these branches into a single repository for ease of perusal, which can be found here.

Week 7

In contrast with the previous weeks of CS50, the course introduces SQL, which is not strictly a programming language but rather a data query language designed for interacting with relational databases. Now, I'm quite familiar with SQL from years of messing with web development and in my day job so this week was a lot easier for me than previous weeks had been. 

The first exercise of problem set 7 has you create a number of SQL queries to run against a database that has been extracted from IMDB. For example, one of the exercises asks you to write a query that lists the titles of all movies in which Johnny Depp and Helena Bonham Carter co-starred. Surprisingly, this only returns 6 results! The database itself follows a pretty sensible layout with tables for people, movies, genres, stars, and so on. 

The second exercise takes a more interesting approach and returns to more traditional styles of problems presented in CS50. The scenario placed before you is that the teachers at Hogwarts want to create a database table with the details of all students - first name, middle name, last name, birth year, and house. Your task is to do this programmatically by accepting a CSV file as input to your program, processing and inserting each line of the CSV into a database table. This was actually fairly easy to do as it leveraged a lot of the skills from Week 6 with its DNA program - except instead of comparing the contents of the CSV dictionary, it ran an SQL command for each line.

The next part of the exercise was similarly simple wherein its job was to run a select query across the database in order to return all students that belonged to a certain house (passed as a command line argument). 

This week was probably the easiest time I've had in CS50 so far. It's starting to touch on the higher level programming that I'm semi-familiar with and helping me rewrite my understanding of how to design elegant programs.

During this week, I also created a Python script for a personal use case - renaming a bunch of photos of figure drawings in a directory to fall in line with a naming scheme. One of the things I really noticed when I was working on this was that I was thinking much more about resolving edge cases and handling errors in the event of unexpected input. I'm keen to keep pushing on and complete CS50 as it has already helped my code so much and is such a great free resource.