Learn the Basics and Get Started with MongoDB

Get into to the world of NoSQL databases

Lynn Kwong
8 min readFeb 24, 2022


MongoDB is an open-source document-oriented NoSQL database. NoSQL, which can be interpreted as “non-SQL” or “not only SQL”, means the data is stored differently from Relational DataBase Management System (RDBMS) where data is stored as tables. As a popular NoSQL database, MongoDB stores data as documents, which are NOT Word documents 😄, but are objects with key/value pairs. If you use Python, you can understand documents as dictionaries. And if you have some knowledge of JavaScript, a document is an object in JavaScript. Note that a MongoDB document is not a JSON, which stands for JavaScript Object Notation and is actually the JavaScript object represented as a string.

Image by AlLes on Pixabay.

Technically, the documents in MongoDB are BSON documents, which are binary representations of JSON documents and support more data types such as ObjectId and Timestamps.

A document in MongoDB corresponds to a row in RDBMS. And the keys of a document then correspond to the columns of a row. Similarly, just as the rows are stored in a table in RDBMS, the documents are stored in a collection in MongoDB. And at the highest level, MongoDB also has the concept of databases that store collections rather than tables.

OK, enough talking. Now let’s get started to work with MongoDB and write some code! It’s more interesting and more efficient to learn MongoDB from examples.

Before we can create a document in MongoDB, we need to have a MongoDB server available. You can use a server hosted by MongoDB Atlas, which is recommended for production usage, or install MongoDB on your computer. However, for learning purposes, it is recommended to use Docker to start a container for MongoDB instead. In this way, you can always use the latest version of MongoDB and can have more flexible settings. Once you know how to use MongoDB, you just need to change the credentials to access your production MongoDB server.

The command to start a Docker container for MongoDB is:

$ docker network create mongo-net$ docker run --detach --network mongo-net --name mongo-server \



Lynn Kwong

I’m a Software Developer (https://superdataminer.com) keen on sharing thoughts, tutorials, and solutions for the best practice of software development.