MongoDB (3)-concepts related to nosql and MongoDB

Source: Internet
Author: User
Tags value store
Document directory
  • About nosql
  • Advantages of nosql
  • Features of nosql
  • MongoDB Introduction
  • MongoDB features
  • Applicable scenarios of MongoDB
  • Nosql Products

It is useless to learn something without understanding it. Just like a developer who only has a few concepts but does not understand it can't help the interviewer. The previous two articles gave a brief introduction to MongoDB. They can get started quickly and have a perceptual knowledge of MongoDB. Most of the content in this article comes from MongoDB's authoritative guide and MongoDB practice. I hope to have a new understanding of this article after learning a complete MongoDB.

About nosql

Nosql stands for "not only SQL", which refers to non-relational databases. These databases have these features: Non-relational, distributed, open-source, and horizontally scalable. The original purpose was to achieve large-scale Web applications. Some people proposed in the early days of this brand-new database revolution that the development trend had increased to a higher level by 2009. Nosql advocates advocate the use of non-relational data storage. common applications such as: Free mode, support for simple replication, Simple API, and final consistency (non-acid) large data capacity. Nosql is the most widely used key-value storage. Of course, there are other document-type, column-type, graphic-type databases, XML databases, and so on. Compared with the overwhelming relational data warehouse, this concept is undoubtedly a new way of thinking.

Advantages of nosql

Compared with relational databases, nosql has the following advantages:

  • It is suitable for high-concurrency database read/write requests.
  • It is suitable for high-efficiency storage and access to massive data.
  • It is suitable for high scalability and availability of databases.

Thanks to these advantages, nosql is suitable for the following scenarios:

  • When the requirements for Database Transaction consistency are not high, because nosql does not support transactions (MongoDB does not support transactions, and others have not done research ).
  • When the requirements for real-time writing and reading of databases are not high.
  • Complex SQL queries, especially when there are not many multi-table join queries.
Features of nosql
  • It can process large amounts of data
  • It runs in a cheap PC server cluster on a server cluster, which means that it is convenient to expand the PC cluster when the database is not enough and the cost is very low.
  • It breaks down the performance bottleneck, because the use of nosql saves the time for converting the traditional program model to SQL, And the execution efficiency is higher.
  • It does not have many operations, meaning that it removes many features that are not actually used in relational databases.
  • Its support supporter originates from the community, and all nosql products are open-source.
MongoDB Introduction

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. It is similar to the JSON bjson format, bson for short. Therefore, it can be used to store complex 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.

MongoDB features

1. Rich data models MongoDB is a document-oriented database. A document in MongoDB is equivalent to a line in a relational database. The document can contain complex data structures, so that a record can represent complex hierarchical relationships. For example, there is a comment field in the article table. In relational databases, we usually create a comment table to associate it with the article table, in MongoDB, you can directly include comments in the document recorded in an article. It is more in line with our thinking. MongoDB has no mode. That is to say, there is no table structure. The fields in the document can be added at any time without affecting the original data, making development easy. 2. It is easy to expand in some large websites, and the data growth is amazing. There are usually two ways to deal with insufficient data growth machines:

  • Purchasing a machine with higher configuration costs a lot, and even if it reaches the physical limit, it cannot buy a higher configuration.
  • To distribute data to multiple machines, which is complex in operation.

MongoDB's design takes into account the scalability issue. It adopts a document-oriented data model that enables Automatic Data cutting across multiple servers. It can also balance the data and load of the cluster and automatically reschedule documents. 3. Rich Functions

  • Index: MongoDB supports common secondary indexes and supports multiple quick queries.
  • Store javascript: you no longer need to use stored procedures. You can directly access JavaScript Functions and values on the server side.
  • Aggregation: MongoDB supports mapreduce and other aggregation tools.
  • Fixed set: the set size is limited, which is useful for logs.
  • File Storage: MongoDB supports storing large files with an easy-to-use protocol (gridfs.

4. faster speed and high performance are the goal of MongoDB. To improve performance, you must perform a lot of streamlined design, which is much less powerful than relational databases, however, it still maintains many features of relational databases. Some simplified designs are shown in:

  • Using the MongoDB transmission protocol as the main way to interact with the server can save a lot of cost compared with HTTP and reset.
  • Dynamic filling of documents, pre-allocating data files, and exchanging space for time are not a problem for the time being.
  • The default storage engine uses memory ing files to handle memory management tasks by the OS.
  • The dynamic query optimizer remembers the most efficient way to execute queries.

5. Perform simple MongoDB management to make the server autonomous to simplify database management. In addition to starting the database server, there are almost no management operations. If the master server fails, MongoDB automatically switches to the backup server and promotes the backup server to an active server. In a distributed environment, the cluster automatically integrates and configures new nodes only when new nodes are available.

Applicable scenarios of MongoDB
  • Website data: MongoDB is ideal for real-time insertion, update, and query. It also supports the replication and high scalability required for real-time website data storage.
  • Cache: because of its high performance, MongoDB is also suitable for serving as the cache layer for information infrastructure. After the system is restarted, the persistent cache layer established by MongoDB can avoid data source overload at the lower layer.
  • Large-sized and low-value data: traditional relational databases may be expensive to store some data. Previously, programmers often choose traditional files for storage.
  • High scalability: MongoDB is ideal for databases composed of dozens or hundreds of servers. The MongoDB roadmap contains built-in support for the mapreduce engine.
  • For object and JSON Data Storage: The bson data format of MongoDB is suitable for storing and querying document-based data.
Nosql Products
Database Architecture Implementation Language
Hypertable Bigtable, column-oriented C ++
Hbase Bigtable, column-oriented Java
Cassandra Dynamo (with bigtable Data Model) Java
MongoDB Auto-sharding C ++
Riak Dynamo, key/Value Store Erlang
Couchdb Document-oriented (non-scalable) Erlang
Redis In-memory, key/Value Store C
Project Voldemort Dynamo Java
Tokyo Cabinet/tyrant Key/Value Store C
Dynomite Dynamo Erlang
Amazon S3 Hosted key/Value Store Java
Amazon RDS Hosted MySQL C
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.