ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

NoSQL 简介 & mongoDB —— 转发

2022-06-21 08:00:25  阅读:317  来源: 互联网

标签:about NoSQL 转发 MongoDB databases database mongoDB data


原文:What Is NoSQL? NoSQL Databases Explained | MongoDB

 

 NoSQL databases (aka "not only SQL") are non-tabular databases and store data differently than relational tables.

 

 NoSQL databases come in a variety of types based on their data model.

The main types are document, key-value, wide-column, and graph.

They provide flexible schemas and scale easily with large amounts of data and high user loads.

 

Brief history of NoSQL databases

 

NoSQL databases emerged in the late 2000s as the cost of storage dramatically decreased.

Gone were the days of needing to create a complex, difficult-to-manage data model in order to avoid data duplication.

Developers (rather than storage) were becoming the primary cost of software development, so NoSQL databases optimized for developer productivity.

 

 

 

As storage costs rapidly decreased, the amount of data that applications needed to store and query increased. This data came in all shapes and sizes — structured, semi-structured, and polymorphic — and defining the schema in advance became nearly impossible. NoSQL databases allow developers to store huge amounts of unstructured data, giving them a lot of flexibility.

 

Additionally, the Agile Manifesto was rising in popularity, and software engineers were rethinking the way they developed software. They were recognizing the need to rapidly adapt to changing requirements.

They needed the ability to iterate quickly and make changes throughout their software stack — all the way down to the database.

NoSQL databases gave them this flexibility.

 

Cloud computing also rose in popularity, and developers began using public clouds to host their applications and data.

They wanted the ability to distribute data across multiple servers and regions to make their applications resilient, to scale out instead of scale up, and to intelligently geo-place their data. Some NoSQL databases like MongoDB provide these capabilities.

 

NoSQL database features

Each NoSQL database has its own unique features. At a high level, many NoSQL databases have the following features:

Check out What are the Benefits of NoSQL Databases? to learn more about each of the features listed above.

 

Types of NoSQL databases

Over time, four major types of NoSQL databases emerged: document databases, key-value databases, wide-column stores, and graph databases.

  • Document databases store data in documents similar to JSON (JavaScript Object Notation) objects. Each document contains pairs of fields and values. The values can typically be a variety of types including things like strings, numbers, booleans, arrays, or objects.
  • Key-value databases are a simpler type of database where each item contains keys and values.
  • Wide-column stores store data in tables, rows, and dynamic columns.
  • Graph databases store data in nodes and edges. Nodes typically store information about people, places, and things, while edges store information about the relationships between the nodes.

To learn more, visit Understanding the Different Types of NoSQL Databases.

 

Difference between RDBMS and NoSQL databases

While a variety of differences exist between relational database management systems (RDBMS) and NoSQL databases, one of the key differences is the way the data is modeled in the database.

 

 

 In order to retrieve all of the information about a user and their hobbies, information from the Users table and Hobbies table will need to be joined together.

 

{
   "_id": 1,
   "first_name": "Leslie",
   "last_name": "Yepp",
   "cell": "8125552344",
   "city": "Pawnee",
   "hobbies": ["scrapbooking", "eating waffles", "working"]
}

  

In order to retrieve all of the information about a user and their hobbies, a single document can be retrieved from the database. No joins are required, resulting in faster queries.

To see a more detailed version of this data modeling example, read Mapping Terms and Concepts from SQL to MongoDB.

 

Other differences between RDBMS and relational databases

While the example above highlights the differences in data models between relational databases and NoSQL databases, many other important differences exist, including:

  • Flexibility of the schema
  • Scaling technique
  • Support for transactions
  • Reliance on data to object mapping

To learn more about the differences between relational databases and NoSQL databases, visit NoSQL vs SQL Databases.

 

Why NoSQL?

NoSQL databases are used in nearly every industry. Use cases range from the highly critical (e.g., storing financial data and healthcare records) to the more fun and frivolous (e.g., storing IoT readings from a smart kitty litter box).

In the following sections, we'll explore when you should choose to use a NoSQL database and common misconceptions about NoSQL databases.

 

When should NoSQL be used?

When deciding which database to use, decision-makers typically find one or more of the following factors lead them to selecting a NoSQL database:

  • Fast-paced Agile development
  • Storage of structured and semi-structured data
  • Huge volumes of data
  • Requirements for scale-out architecture
  • Modern application paradigms like microservices and real-time streaming

See When to Use NoSQL Databases and Exploring NoSQL Database Examples for more detailed information on the reasons listed above.

 

 

NoSQL database misconceptions

Over the years, many misconceptions about NoSQL databases have spread throughout the developer community. In this section, we'll discuss two of the most common misconceptions:

  • Relationship data is best suited for relational databases.
  • NoSQL databases don't support ACID transactions.

To learn more about common misconceptions, read Everything You Know About MongoDB is Wrong.

 

Misconception: relationship data is best suited for relational databases

A common misconception is that NoSQL databases or non-relational databases don’t store relationship data well. NoSQL databases can store relationship data — they just store it differently than relational databases do.

In fact, when compared with relational databases, many find modeling relationship data in NoSQL databases to be easier than in relational databases, because related data doesn’t have to be split between tables. NoSQL data models allow related data to be nested within a single data structure.

 

Misconception: NoSQL databases don't support ACID transactions

Another common misconception is that NoSQL databases don't support ACID transactions. Some NoSQL databases like MongoDB do, in fact, support ACID transactions.

Note that the way data is modeled in NoSQL databases can eliminate the need for multi-record transactions in many use cases. Consider the earlier example where we stored information about a user and their hobbies in both a relational database and a document database. In order to ensure information about a user and their hobbies was updated together in a relational database, we'd need to use a transaction to update records in two tables. In order to do the same in a document database, we could update a single document — no multi-record transaction required.

 

While we don't need to think about database design for this tutorial, note that database design and data modeling are major factors in MongoDB performance. Learn more about best practices for modeling data in MongoDB:

 

When you are ready to try more advanced queries that aggregate your data, create an aggregation pipeline. The aggregation framework is an incredibly powerful tool for analyzing your data. To learn more, take the free MongoDB University Course M121 The MongoDB Aggregation Framework.

 

When you want to visualize your data, check out MongoDB Charts. Charts is the easiest way to visualize data stored in Atlas and Atlas Data Lake. Charts allows you to create dashboards that are filled with visualizations of your data.

 

 

Summary

NoSQL databases provide a variety of benefits including flexible data models, horizontal scaling, lightning fast queries, and ease of use for developers.

NoSQL databases come in a variety of types including document databases, key-values databases, wide-column stores, and graph databases.

 

MongoDB is the world's most popular NoSQL databaseLearn more about MongoDB Atlas, and give the free tier a try.

Excited to learn more now that you have your own Atlas account? Head over to MongoDB University where you can get free online training from MongoDB engineers and earn a MongoDB certification. The Quick Start Tutorials are another great place to begin; they will get you up and running quickly with your favorite programming language.

 

标签:about,NoSQL,转发,MongoDB,databases,database,mongoDB,data
来源: https://www.cnblogs.com/panpanwelcome/p/16395437.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有