Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function and usage of MongoDB in NoSQL document storage database

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

In the NoSQL document storage database in the role and usage of MongoDB, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

I. NoSQL database classification

MongoDB is a database based on distributed file storage. Written in C++ language. Designed to provide scalable high-performance data storage solutions for WEB applications. MongoDB is a product between relational database and non-relational database, which is the most functional and most like relational database in non-relational database.

There are a large number of NoSQL databases, but they can be divided into four categories as shown in the following figure:

Key-value storage database: database representative-- Redis

Column storage database: database representative-- HBase

Document storage database: database representative-- MongoDB

Graphic database: database representative-Neo4J.

What is MongoDB

Relational database: in the sqlserver, mysql, etc., which we have used, these are relational databases, and relational databases follow the ACID principle and are strictly consistent.

Non-relational database: also known as NoSQL, with very large-scale data storage, these types of data storage do not need a fixed schema and can be scaled out without redundant operations.

MongoDB is written in C++ language and is an open source database system based on distributed file storage. In the case of high load, adding more nodes can ensure server performance. MongoDB aims to provide scalable, high-performance data storage solutions for WEB applications. MongoDB stores the data as a document, and the data structure consists of key-value (key= > value) pairs. MongoDB documents are similar to JSON objects. Field values can contain other documents, arrays, and document arrays.

Third, the advantages and disadvantages of Mongodb and its suitability for scenarios

MongoDB is a database for the Internet and a document database.

1.1. Advantages:

Schema-less, there is no need to predefine the table structure, and multiple formats of data can be saved in the same "table".

Data supports nesting and is stored in json format

Allows you to write server-side scripts using JavaScript, similar to stored procedures

Support for Map/Reduce

MongoDB supports geographic location index, which can be directly used for location distance calculation and query to achieve "people nearby",

It is easy for Didi Taxi to take the order.

1.2. Disadvantages:

Mongodb does not have "data consistency check", "transaction", etc., and is not suitable for storing data that requires high data transactions (such as finance); it is only suitable for storing non-critical data (such as logs or caches).

The associated query is very weak and is not suitable for report query.

1.3.The Mongodb is suitable for the scene

1), the log record of the application server.

2), mainly used to store some monitoring data, No schema is really convenient for developers, adding fields do not need to change the table structure, and the learning cost is very low.

3) use MongoDB to do O2O express application, store the information of delivery riders and couriers (including location information) in MongoDB, and then query the geographical location of MongoDB, which is very convenient to find nearby merchants, riders and other functions, so that express riders can receive orders nearby.

1.4. scenarios that are not suitable for MongoDB

If there are a large number of complex transaction logic operations in the business, do not use the MongoDB database.

IV. Summary

In mongodb, the concept of "table" in relational database is "set". The data structure in the table is consistent. Mongodb is stored in json format, and the collection data is flexible. Different structures of data can be stored in the same collection collection of mongodb. But in practice, A Bun does not recommend that we store different objects in the same MongoDB's Collection.

NoSQL document storage database-MongoDB

After sharing this course, please remember that do not apply MongoDB NOSQL database like RDBMS relational database! It is recommended that data that is not frequently modified be placed in MongoDB. Mongodb can never replace the databases such as sqlserver,mysql,oracle that we use every day. The two can only complement each other and learn from each other.

Summary: NoSQL is suitable for situations where the data model is simple and does not require a high degree of data consistency, but requires high performance and flexibility.

Remember one thing: if you use it and you suddenly find that you are using mongodb as a RDMS relational database, it is your fault! Mongodb is only suitable for storing solidified and unstructured data forever!

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report