mongodb overview

Recently I read the mongoDB’s documentation. Here I listed some important features of MongoDB that are different from other databases’.

What is MongoDB?

It’s a NoSQL document database.

How is data stored in MongoDB? How does MongoDB provide durability? How does MongoDB handle large files?

The storage engine is the primary component of MongoDb responsible for managing data, both in memory and on disk. You can choose the appropriate storage engine to suit your application.
MongoDB use write-ahead logging to on-dis journal files to provide durability and prevent failture. It uses GridFS to handle large file.

What kind of operations can MongoDB perform?

Most of the SQL operations work well including aggreation. The new MongoDB has join feature but the speed probably won’t be that good compared with others.

Any interesting features in MongoDB structure? What are indexes in MongoDB?

The basic structure is Database.Collection.Documents(usually Json Format). Each document has a unique id used as a primary key.

Indexes are special structures in MongoDB, which stores a small portion of the data set in an easy to traverse form. There are various kinds of indexes that MongoDB supports.

MongoDB also support geospatical data querying as well as reference link between two different documents.

What are some common administration tools used in MongoDB?

Profiler is used to track commend’s performance.
Change streams allow applications to access real-time data changes without the complexity and risk of tailing the log.

How replication works in MongoDB?

The replication design in MongoDB is really similar to Kafka. It has a primary node for all the write operations and can use any node for read operations. Heartbeat is used among nodes to show the node’s current condition. When the primary node fails, an eligible secondary node would hold an election to elect itself the new primary. Other secondary nodes would check various conditions such as whether their have stable connections with the candidate without long delay in data transformation. If the candidate has more than half vote, it will be selected as the primary node. There are also nodes called Arbiter that are considered as vote only.

What is sharding in MongoDB?

The procedure of storing data records across multiple machines. We carefully choose a sharding key to distribute the documents in a collections. The sharding key can't be changed.

What other interesting features do you think MongoDB has?

I haven’t used it much and learned it only by reading documentation, so here are simply some random notes I have so for.

  1. It’s really convenient to create and run function in MongoDB.
  2. You can customize prompt to for example display your database and hostname.
  3. It accepts retryable write that allows drivers to automatically retry certain write operation a single time if they encounter network errors.
  4. MongoDB also support transactions to ensure atomicity for updates to multiple documents or consistency between reads to multiple documents.

What are the drawbacks of MongoDB?

  1. It doesn’t support Join.
  2. It is a memory hog. Because MongoDB stores key names for each value pairs. There is data redundancy since there is no join.
  3. The scaling ability and pipeline operations are not so well compared with other NoSQL solutions.
  4. The transaction can only happen at the document level.