Mongo MOOC

I just completed M101P: MongoDB for Developers! This is a free online course that uses the edX platform, but is not offered through Instead, it is offered directly from MongoDB (formerly 10gen).


As the name implies, it’s an introduction to MongoDB, a database that is not a relational database, but a document store. Last year, I took the Stanford database course which mentioned all sorts of databases, including MongoDB, but mostly focused on relational databases (there was a unit on NoSQL, but it had no exercises). As such, this course made a nice follow-up to that one.

Manipulexity v. Whipuptitude

One of the first lessons explains the motivation for MongoDB with a plot showing where Mongo fits in between the scalability of a key-value store and the functionality of an RDBMS.


Figure 1: Manipulexity v. Whipuptitude?

This struck me as analogous to Larry Wall’s motivation for creating Perl; he wanted something in between the manipulexity of C and the whipuptitude of shell! Since Perl is one of my favorite programming languages (by far the one I’ve used the most), this analogy bodes well! If Mongo fits into the database world similarly to the way Perl fits into the programming world, I think I will like it!


The course recognizes only two kinds of computers: Macs and PCs. Since I use Linux machines almost exclusively, I have had to learn to cope with this view of the world. It’s pretty popular among the general population. But not for developers usually. It feels especially odd here since MongoDB is probably running on more Linux machines in the world right now than all other machines combined.

Fortunately, installing MongoDB on my laptop running Ubuntu was dead simple

sudo apt-get install mongodb-server mongodb-clients mongodb-dev

Ubuntu 13.10 has MongoDB 2.4.6, which is pretty up-to-date (the latest is 2.4.8). For this course, MongoDB 2.2 or newer will suffice. Note that Ubuntu 12.04 (the most recent LTS) supplies MongoDB 2.0. This lacks the aggregation framework, so it would not be sufficient for this course.

In the course video, they download MongoDB to a Mac, create a data directory in /data/db, and then start the server by changing to the bin directory and executing mongod. Using the Ubuntu package, the server is already running and it’s using /var/lib/mongodb as a data directory. So there’s nothing else to do!

$ mongo
MongoDB shell version: 2.4.6
connecting to: test

Here mongo, the command line MongoDB client, connects to our running server and gives us a prompt. It’s basically a JavaScript REPL with some extensions for doing MongoDB stuff

> 2 + 2

Easy peasy lemon squeezy!


There are actually several versions of this course. This one uses Python. As such, we needed to install pymongo, the driver that enables our Python programs to communicate to MongoDB. In the course video, they download it manually and run easy_install as root…gah! Again, if you ignore that advice, it’s really quite simple to do

$ pip install pymongo

The course also creates a web application and for that they use Bottle, a nice little web framework that I was unfamiliar with (originally a fork of Flask, I guess). Again, it installs easily

$ pip install bottle

Even though both pymongo and Bottle work fine in Python 3, the course uses Python 2 for some reason. I found this particularly odd because I think of MongoDB as a new thing. I mean, their whole business is based around convincing people to eschew decades of database research and try this new way instead. If anyone was going to embrace Python 3, I would have thought it would be the MongoDB folks. Anyway, I started out converting everything to Python 3, but eventually I gave up and installed Python 2.7.6 and used that for the rest of the course.

The sample Python code left a lot to be desired, even given that it was Python 2. In addition to using the print statement instead of the print function and %s instead of string format, it was loaded with bare except statements. That was never good form, even in Python 2. And they incremented variables with “i = i + 1,” explaining that Python lacks i++ (yes, but it has i += 1, so we needn’t repeat the name). Also, they use classic classes everywhere!

There were also issues with the inline quizzes. This appeared to be because they were doing string matching when they should have been evaluating. For example, I got this wrong

Write the to code to initialize a list with the items "hammer", "nail"
and "wall" and assign the list to the variable named "things".

because I wrote

things = ['hammer', 'nail', 'wall']

and they only accepted

things = ["hammer", "nail", "wall"]

These, of course, are equivalent in Python.

Despite all of these issues, I think Python is a good choice for this course. I wish they had used an up-to-date Python and I wish they had used more idiomatic Python, but in the end it didn’t really affect the course too much. How to use MongoDB from Python was effectively communicated. Indeed, I’m sure you can extrapolate everything to any similar language. I tried several of the examples and exercises in Perl and things worked nearly the same way. I’m confident I could easily do things in Ruby as well.


The bulk of the course went very well. The edX platform was easy to use (I had some difficulty with the edX demo course, but none with the MongoDB course). It’s very similar to Class2Go, which is what was used for the Stanford database class. Most lessons consisted of a video lecture, a quiz, and its answer. There is some discussion in some of the answers. It took a me a while to catch on to this. Early on, if I got the answer right, I didn’t look at the answer video. After I got a few wrong, it dawned on me that there was good stuff in some of those answer videos! After that I started watching all of them, even when I got the right answer.

The final exam was harder than I expected. Most of the course was pretty easy to follow, so I guess I was expecting a pretty easy final as well. That was not the case. It was actually pretty challenging. I got what was probably the easiest question wrong because I didn’t submit the answer correctly. It was a pretty straightforward update, but we weren’t supposed to merely provide the update command. Instead, we were meant to execute on some unseen database. The confusion was worsened because you couldn’t go back and look at your answer afterwards. In any case, I’m certain I did it right (I ran it locally), I just didn’t submit it right.


Overall, I think the course was very worthwhile. Compared to a relational database, MongoDB is a joy to use from programming languages and I think going through this course saved me a lot of the trouble of discovering stuff on my own.

If you’re interested, there’s another section starting soon!

Mongo MOOC