Storing and retrieving data with MongoDB
MongoDB is a NoSQL database offering that maintains a philosophy of performance over features. It's designed for speed and scalability. Instead of working relationally, it implements a document-based model that has no need for schemas (column definitions). The document model works well for scenarios where the relationships between data are flexible and where minimal potential data loss is an acceptable cost for speed enhancements (a blog, for instance).
While it is in the NoSQL family, MongoDB attempts to sit between two worlds, providing a syntax reminiscent of SQL but operating nonrelationally.
In this task, we'll implement the same quotes
database as in the previous recipe, using MongoDB instead of MySQL.
Getting ready
We want to run a MongoDB server locally. It can be downloaded from http://www.mongodb.org/downloads.
Let's start the MongoDB service, mongod
, in the default debug
mode:
mongod --dbpath [a folder for the database]
This allows us to observe...