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

Data storage in big data era, non-relational database MongoDB

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Exploding NoSQL Technology

Relational Database Management System (RDBMS) has been the dominant database solution for a long time, which uses real-world things and relationships to explain abstract data structures in databases. However, in today's explosive development of information technology, big data has become a new technological revolution after cloud computing and Internet of Things. Relational databases have begun to struggle when dealing with large amounts of data. Developers can only solve the problem of data volume by continuously optimizing databases. However, optimization is not a long-term solution, so people have proposed a new database solution to meet the arrival of the era of big data-NoSQL (non-relational database).

NoSQL is very young, but it has many excellent features that many enterprises and developers have begun to accept. Let's take a look at the database ranking from DB-engines, a US database knowledge website, last month.

As you can see from the rankings, MongoDB stands out from many RDBMS (relational databases), has become the fifth place, and is still rising.

If the database was compared to humans, MongoDB could be said to be a child prodigy. At the age of 5, he challenged a group of uncles alone. Moreover, according to the development speed in recent years, he was about to surpass PgSQL and become the fourth place. Although there was still a certain distance between him and the three rich children with NB fathers, what was impossible in such an era of technological explosion?

Why MongoDB?

1. performance

In the era of big data, the processing of large amounts of data has become one of the most important reasons to consider a database. One of MongoDB's main goals is to keep the database performing as well as possible, which largely determines MongoDB's design. In an era dominated by traditional mechanical hard disks, hard disks are likely to be performance weaknesses, and MongoDB chooses to maximize memory resources for caching in exchange for superior performance, and automatically selects the fastest index for queries. MongoDB keeps the database as lean as possible, handing off as many operations as possible to clients, which is one of the reasons MongoDB maintains excellent performance.

2. extended

Now the amount of data on the Internet has changed from MB and GB in the past to TB level now. A single database obviously cannot bear it. Scalability has become an important topic. However, developers often make difficulties when choosing the expansion method. Is it horizontal or vertical?

Scale out is the splitting of a database into different chunks distributed among different machines in a way that adds partitions. This has the advantage of low cost but difficult to manage.

Scale-up Scale-up differs from scale-out in that it upgrades the original server to have more computing power. The advantage of this is that it is easy to manage without considering the many problems brought about by expansion, but the disadvantage is also obvious, that is, high cost. A mainframe is often expensive, and such upgrades may not be able to find a more powerful machine when the data reaches its limit.

MongoDB chose to scale out more economically, making it easy to split data across different servers. Moreover, developers do not need to consider the problems caused by multiple servers when obtaining data. MongoDB can automatically route developers 'requests to the correct server, allowing developers to focus on the development of the program instead of the disadvantages caused by horizontal expansion.

3. use

MongoDB uses a NoSQL design approach that allows for more flexible manipulation of data. In traditional RDBMS, you must have encountered dozens or even hundreds of complex SQL statements. Traditional RDBMS SQL statements contain a large number of associations, subqueries and other statements, which increase complexity and make performance tuning more difficult. MongoDB's document-oriented design uses a more flexible document as a data model to replace rows in the RDBMS. The document-oriented design allows developers to obtain data in a more flexible way, and developers can query complex nested relationships with only one statement, so developers don't have to struggle to obtain data.

The Impact of NoSQL on Traditional Database Design Thinking

1. Pre-designed vs. dynamic patterns

In traditional database design thinking, the field name and field type in the database table need to be specified in the design phase of the project. If you try to insert data that does not conform to the design, the database will not accept this data to ensure the integrity of the data.

MySQL

--Database fields:NAME, SONG

INSERT INTO T_INFO VALUES('John','Come Together'); --Success

INSERT INTO T_INFO VALUES ('Xiaoming ', 20, ' xiaoming@111.com'); --Failed

--Database fields:NAME, SONG

INSERT INTO T_INFO VALUES('John','Come Together'); --Success

INSERT INTO T_INFO VALUES ('Xiaoming ', 20, ' xiaoming@111.com'); --Failed

NoSQL is used to dynamically append documents (similar to "rows") in a collection (similar to "tables"). At the beginning of the creation of a collection, there is no restriction on the data type. Any document can be appended to any collection. For example, we can add two such documents to a collection:

MySQL

{"name" : "John", "song" : "Come Together"}

{"name" : "Xiaoming", "age":"20", "email" : "xiaoming@111.com"}

{"name" : "John", "song" : "Come Together"}

{"name" : "Xiaoming", "age":"20", "email" : "xiaoming@111.com"}

The format of documents in MongoDB is similar to our common JSON. It can be seen that our first one has two fields of "name" and "song", while the second one has three fields of "name","age" and "email". It is impossible to insert successfully in the database in the pre-design mode, but it is possible in the dynamic mode of MongoDB. The advantage of doing so is that we do not have to design a separate table for some fields with a small number but many types. They can be stored in a single table. But the drawbacks of doing so are also obvious. We need to distinguish between different documents of the same table when obtaining data, increasing the amount of code on development. So at the beginning of the design, you need to weigh the advantages and disadvantages of dynamic schema to choose the data type in the table.

2. Normalization and anti-normalization

Normalization is a concept proposed by Edgar Coder, inventor of relational models, in 1970. Normalization disperses data into different tables and uses relational models for correlation. The advantage of this is that when it is modified later, it will not affect the data associated with it. It can be completed only by modifying itself.

Denormalization is the opposite of normalization, which centralizes the data of the current document into this table rather than storing it in a split form.

There is no trade-off between normalization and denormalization. The advantage of normalization is that it provides higher performance when we write, modify, and delete, while denormalization improves our performance when we query. Of course, there is no associative query in NoSQL to improve query performance, but we can still normalize it by storing the associative table ID in the table. However, it can be seen that the position of anti-normalization in the concept of NoSQL is greater than that of normalization.

MongoDB is still young.

MongoDB has many excellent designs, but MongoDB still has many problems that it is not good at, including:

MongoDB does not support transactions, and many software programs still need transaction management, so programs with high transaction consistency requirements can only be managed at the software level, and cannot be managed from the database.

The range of support for other tools, MongoDB has been less than 5 years since its release, so there are many languages that do not have a corresponding toolkit, so if you do not have a corresponding package for the language you are using, it may be the biggest obstacle that prevents you from using MongoDB.

Community resources, this problem is the same as the second problem because MongoDB is too young, compared to other large database communities, MongoDB is obviously not comparable, but community is often one of the important factors to consider, lack of community resources will lead to problem solving cycle extension, thus delaying work.

The rapid development of technology in recent years is exciting, every year there will be eye-catching products, however, it takes time to accumulate to become a mature product, MongoDB still needs to grow, but his excellent design, will certainly let more and more developers accept it

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

Internet Technology

Wechat

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

12
Report