Introduction to MongoDB database features and benefits

  • 2020-05-27 07:27:03
  • OfStack

The year 2011 will be remembered as the year SQL will die; In this year, the relational database drops from line 1; This year developers discovered that they did not need to convert each object into a table structure in order to persist the data.

2011 was the year of the document database, and while it has been growing steadily over the last eight years, there are now a variety of stable document databases -- from the amazon and google-based cloud to various open source tools, especially MongoDB.

So, what is MongoDB? Here are five things every developer should know:

1) MongoDB is an independent server;

As with MySQL or PostreSQL 1, MongoDB provides listening ports for access. It provides tools for querying, creating, updating, and deleting. In theory, you use it the same way: connect, perform the task, and close the connection.

2) it is document-based, not table-based;

MongoDB has no structured language. If you want to create a new document type, you don't have to do anything to tell the database about the structure of the data, just store it in the database.

Simply put, MongoDB USES a type handling similar to JavaScript or PHP. In other words, the database is a flexible weak type.

Although some data is limited (large chunks of data may require some explicit processing), in most cases you can write your MongoDB code as if it were PHP code 1.

3) it is unstructured;

Remember those database abstraction layers you wrote? Remember those ORM layers you worked on? Now, you can throw them all away. You don't need them in MongoDB. MongoDB does not have many query statements. In most cases, just give it an array of the information you want, and it will give you an array of the returned documents. If you want to run some very complex queries (such as Map-Reduce), you can pass JavaScript to MongoDB, whose internal JavaScript engine can parse the script.

4) no need to learn another query language;

Development time is also short, because there is no structure to manage and very little, if any, data mapping.

The learning curve is smooth because there is no new query language learning. The code is clean. After all, there is no need for any other ORM, and encapsulation can be very simple. Your code is a guarantee of the future. It's easy to add more fields to your object. As a result, the requirements change and you can quickly modify the code to accommodate them.

MongoDB was enough to make me realize its game-changing potential. This is why it is recommended to use a new generation of document databases instead of SQL-based relational databases. Leaving relational databases in the dust is more likely to let them do what they do well: store data that belongs to rows and tables.

MongoDB is a document-oriented database developed by C++, which is an anti-traditional database model. It records all relevant objects into one document, and each document is schema-free. In other words, the column name can be defined freely, which is quite flexible, especially in the face of the application scenarios with changeable business logic. Data is stored in base 2 in BSON (similar to JSON) format. The downside is the potential for data redundancy and storage overhead.

In addition, the indexing mechanism of MongoDB is the same as that of MySQL, so you can use the experience of traditional relational databases to use the indexes of MongoDB.

Unlike many other NoSQL products developed by individual engineers based on application scenarios, MongoDB is maintained by a dedicated company, 10gen. One thing to note is that MongoDB itself does not manage memory and cannot specify the size of the memory. It is completely left to the operating system to manage, so it is sometimes out of control. You must monitor memory usage at the OS level when using it in a production environment.

5) it has strong mainstream development language support, such as C#, C++, Java, PHP, Perl, Python, Ruby.


Related articles: