MongoDB getting started

Source: Internet
Author: User

I. Basic Concepts

MongoDB is a high-performance, open-source, and non-pattern document-based database. It is currently the most popular NoSQL database product. It can be used in many scenarios to replace traditional relational databases or key/value storage methods. MongoDB is developed using C ++. The official website address of MongoDB is http://www.mongodb.org/. you can provide more detailed information here.

MongoDB is a product between relational databases and non-relational databases. It has the most abundant functions and features like relational databases. The supported data structure is very loose and is similar to the json bjson format. Therefore, it can store complicated data types. The biggest feature of MongoDB is that it supports a very powerful query language. Its syntax is a bit similar to an Object-Oriented Query Language. It can almost implement most of the functions similar to single-table queries in relational databases, it also supports data indexing. It is a set-oriented, free-of-charge document-type database.

Ii. Comparison

 

MongoDB

Relational Database Service

Data Storage

Set-oriented

Relational table

Data Structure

Free mode

Relational table Relationship Mode

Transactions

Not Supported

Supported

Large data (video)

Good

Average

Large data volume query (more than 10 million records)

Good

Poor

Database Maintenance

Relatively simple

Relatively complex

Data and table relationship and structure browsing

Difficult

Simple

Data security

Poor

Good

Distributed

Good

Average

Query

Very flexible

Very powerful

Primary foreign key Association

Not Supported

Supported

Index

Supported

Supported

Stored Procedure

Supported

Supported

Iii. Comparison

1. Data Storage

MongoDB is a collection-oriented collection that contains multiple documents and supports object-type data storage. The concept of integration and documentation is similar to table and metadata in relational databases (row: that is, a row of data ). In addition, MongoDB is stored in the form of bson, while relational databases are stored in the form of two-dimensional relationships.

2. Data Structure

MongoDB provides flexible support for data structures, from horizontal to vertical. For example, the following data can be stored in the same collection:

① {"Name": "wangwu", "age": 25}

② {"Name": "lisi "}

③ {"State": "activated", "remark": "none "}

④ {"Name": 6, "age": "You guess "}

From the above example, we can see that the field can be dynamically increased or decreased (such as ① and ②) in the horizontal aspect, and the Field Data Type Hybrid storage (such as ① and ④) is supported in the vertical aspect ). In relational databases, this type of storage cannot be achieved.

3. Transactions

MongoDB itself does not support transaction processing and can only be ensured through program code.

4. Large Data

MongoDB not only supports structured data, but also supports the storage of unstructured data (such as audio, video, documents, XML, and HTML). Although relational databases support the storage of large data (such as videos, however, no matter in terms of storage efficiency or acquisition speed, MongoDB can use efficient binary to store large data.

5. query large data volumes

MongoDB can query more than 10 million data records at a very high speed. This is a major pain point in relational databases.

6. Database Maintenance

MongoDB is very simple in database backup and restoration, as well as data import and export operations. It can be completed with simple commands. It also supports master-slave mode and mutual replication between servers. The primary goal of replication is to provide redundancy and automatic failover, while relational databases are more complex in operation and difficult to get started.

7. Data and table relationship and structure browsing

Because MongoDB does not have a very good GUI client, it is very difficult and clumsy in data browsing and table relations and structure browsing. Relational databases have obvious advantages in this regard.

8. Data Security

MongoDB is relatively poor in data security. If you are slightly careful or improperly performing operations, it may easily cause data loss or data errors. Therefore, you must be very careful in data maintenance and operations. However, there are fewer concerns about relational databases in this regard.

9. Distributed

MongoDB is ideal for databases composed of dozens or hundreds of servers. Supports automatic sharding to support cloud-level scalability. The automatic sharding function supports horizontal database clusters and allows you to dynamically add additional machines. Relational databases are more difficult and complex in Distributed support and operations.

10. Query

The query statements of MongoDB are very different from those of relational SQL statements, or both of them have good performance. MongoDB is mainly reflected in the flexibility and ease of use, SQL is reflected in the comprehensive and powerful functions.

11. Primary foreign key Association

MongoDB does not support primary/foreign key Association, nor does it have a "constraint" concept.

12. Index

MongoDB also supports indexing.

13. Stored Procedure

MongoDB also supports stored procedures.

 

Iv. Summary

Through the comparison above, we can see that MongoDB is designed to sacrifice security, transactions, and structures in exchange for simplicity, efficiency, and flexibility. Therefore, both relational and non-relational databases have their applicability, the emergence of non-relational databases has provided us with an alternative path, thus providing us with great help in data maintenance and storage, making us more comfortable in software development, therefore, people who are traditional and conservative about relational databases can try to experience non-relational databases. Maybe you will be fascinated by them in the first place, mastering a non-relational database is also very beneficial for your future development.

So the introduction to MongoDB will come here first. I will give a systematic summary and introduction of the specific content of MongoDB in the future, hoping to help those who need it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.