当前位置:网站首页>What is NoSQL?Databases for the cloud-scale future

What is NoSQL?Databases for the cloud-scale future

2022-08-02 08:22:00 DebugUsery

什么是NoSQL?Cloud scale oriented database in the future

SQLDatabase of data types and consistency restrictions.为了速度、Flexibility and size,NoSQL取消了这些限制.

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Share on Reddit
  • Share by Email
  • Print resource

Serdar Yegulalp作者 :Serdar Yegulalp

InfoWorld高级撰稿人

MaxiPhoto / Getty Images

在开发一个应用程序时,One of the most basic choice is to useSQL数据库还是NoSQL数据库来存储数据.传统的数据库,即使用SQL(结构化查询语言)A relational database query,Is technology development for decades、The product of good practice and real world pressure test.它们是为可靠的交易Designed and temporary query,Is the main content of the line of business application.但它们也有一些限制,Such as the rigid mode,Make them less suitable for other types of applications.

NoSQLDatabase are against these restrictions.NoSQLThe way the system to store and manage data,Allow high operation speed and the developer's huge flexibility.Many database is composed of Google、亚马逊、雅虎和Facebook等公司开发的,They sought a better way to store content or data processing large web.与SQL数据库不同,许多NoSQLDatabase can be conducted on hundreds or thousands of servers scale out.

[也在InfoWorld上:How to choose the cloud database] .

不过,NoSQLThe advantage of not without cost.NoSQLSystems tend to speed and scalability,而不是SQLReliable database promised deal behindACID属性.在NoSQLFor processing data in the system of metaphor is also a relatively new,与围绕SQLDecades of institutions established knowledge than.

SQL和NoSQLDatabase provides different weigh.Although they may have competition under the background of a particular project--例如,为这个应用或那个Application to choose which one--But they are complementary in a larger range of.Each of which is suitable for the usage of different.Decision is not an either/or,It's a matter of what kind of tools for work.

NoSQL与SQL

SQL和NoSQLThe fundamental difference between is not complicated.On how to store and retrieve data,Both have different ideas.

对于SQL数据库,All data has an inherent structure.像Microsoft SQL Server、MySQL、PostgreSQL或OracleThe database to the traditional database using a模式--一个About how data will be inserted into the database of the formal definition of.例如,A column in a table may be restricted to only integer.因此,Recorded in the column there will be a high degree of standardization of data in.SQLDatabase of rigid pattern also makes for data aggregation is relatively easy to,例如,使用SQLJOIN Command incorporates the two tables of data.

在NoSQL中,Data can be stored in the form of no pattern or freedom.Any data can be stored in any record.在NoSQL数据库中,You will find four common data storage mode,This led to the four commonNoSQL系统类型.

  1. 文档数据库 (如MongoDB).Insert data with schemalessJSON结构或 "文档 "的形式存储,The data can be anything,From integer to a string to a free-form text.No internal demand to specifyJSONDocument which will contain the fields(如果有的话).
  2. 键值存储(如Redis).The value of the free form,From simple integer or a string to the complexJSON文档,In the database to be accessed by means of key,如字符串.
  3. 宽列存储 (如Cassandra).数据被存储在列中,而不是像传统SQLIn the system line.Any number of columns(And many different types of data)Can be according to the needs of data query or view group or aggregate.
  4. 图形数据库 (如Neo4j).Data is represented as entities and relationship network or graphics,Which each node is a free form of a graphic data block.

Schemaless data is stored in the following case is a useful.

  • Do you want to fast access to data,You care more about access speed and simplicity,Rather than a reliable trading or consistency.
  • You are storing a large amount of data,You don't want to lock myself in a mode,Because after the change pattern is likely to be slow and painful.
  • You are receiving unstructured data from one or more sources,You want to keep the original form of data to achieve maximum flexibility.
  • Do you want to store data in a layered structure,But you want the hierarchical structure is described by the data itself,Rather than by the external schema describes.NoSQLAllow the data randomly self reference,The way toSQLDatabase is more complicated,难以模仿.

查询NoSQL数据库

A relational database using结构化查询语言提供了一种统一的方式,In the store and retrieve data communication with the server.SQLGrammar is highly standardized,So while the database may handle some operating in different ways(例如,窗口函数),But the basic principle is still the same.

相比之下,每个NoSQLDatabase often have their own syntax to query and manage data.例如,CouchDB使用JSON形式的请求,通过HTTP发送,以创建检索The database of the文档.MongoDBThrough the binary protocol,Send in the form of command line interface or corpusJSON对象.

一些NoSQL产品可以使用类似SQLGrammar to process the data,但只是在有限的范围内.例如,Apache Cassandra,A wide range of storage,Have their own similarSQL的语言,Cassandra查询语言或CQL.CQLSome of the grammar is directly fromSQL游戏手册,比如SELECTINSERT 关键字.但在Cassandra中没有执行JOIN Or the subquery local method,Therefore relevant keywords in theCQL中不存在.

无共享的架构

NoSQLSystem is a common design option is "无共享 "架构.In the design of a Shared nothing,Each of the servers in the cluster nodes are independent of the other nodes run.Systems don't have to get agreement from other nodes to return data to the client.查询速度很快,Because they can be returned from the nearest or most convenient node.

Another advantage is that the elastic without sharing system and scale out.Extension cluster as start a new node in the cluster and wait for them with the other nodes is as easy as.如果一个NoSQL节点发生故障,Other server in the cluster will continue to run.所有的数据都是可用的,Even if available to service request node to reduce.

请注意,No Shared design isn'tNoSQL数据库所独有的.许多传统的SQLSystem can be set in the form of Shared nothing,如MySQL,Though this often involve the sacrifice of the entire cluster consistency to gain performance.

NoSQL的局限性

如果NoSQLA so much freedom and flexibility,Why don't you completely give upSQL?简单的答案是,Many applications still needSQLDatabase provided by the various constraints、Consistency and safeguards.在这些情况下,NoSQL的一些 "优势 "May become disadvantage.Other restrictions fromNoSQLSystem lacks some inSQLThe function of the field of it.

没有模式

Even if you are free form is acceptable for the data,You almost always need to impose constraints on the data,以使其有用.对于NoSQL,Impose constraints involved will shift the responsibility from the database application developers.例如,Developers can use an object relational mapping system(或称ORM)Imposing structure.But if you wantWith the data itself共存,NoSQLUsually does not support to do so.

一些NoSQLSolution for the data provides an optional data type and authentication mechanism.例如,Apache Cassandra有一系列的本地数据类型,Reminiscent of the traditionalSQL中的那些数据.

最终的一致性

NoSQLSystem provides a selection,With powerful or instant consistency in exchange for better usability and performance.The traditional database to ensure operations are原子性的(All parts of the deal to success,或者没有成功),一致性的(All users have the same comment on data),隔离的(Trading is not competitive),和持久的(一旦完成,They will be survived in the server failure).

这四个属性,统称为ACID,在NoSQLProcessing system can be used in different ways.你可以选择最终一致性,Not require the entire cluster of strong consistency,This will delay response to our request,This allows the service request is,Without waiting for the latest write to be copied to other cluster nodes.Insert the cluster data finally is available everywhere,But you can't promise anything.

对于一些NoSQL系统,You can choose a compromise between consistency and speed,Although different products have different solutions.例如,微软的Azure Cosmos DB可以让你Select each request consistency level,So you can choose to suit your usage behavior.交易语义,在SQLIn the system to ensure all the steps in the deal(Such as implement sales减少库存)要么完成,要么回滚,在一些NoSQL系统中也可以使用,如MongoDB.

NoSQLThe lock of the qualitative

大多数NoSQL系统在概念上是相似的,但实现方式不同.How to query and manage data,Each system has its own mechanism of metaphor and.

To do this is a side effect of application logic and database may exist between the height of the coupling.如果你选择一个NoSQLSystem and stick to it,The coupling is not bad,But if you change the system in the future,It will become a stumbling block to.

如果你从MongoDB迁移到CouchDB(或者相反),You have to do is not only a migration data.You also have to control the data access and procedural metaphor difference.换句话说,You have to rewrite your application to access the database part.

NoSQL技能

NoSQLAnother disadvantage is the relative lack of professional knowledge.传统SQLTalent market is quite big,而NoSQLThe skills of market has just started.

作为参考,Indeed.com报告称,截至2022年,传统SQL数据库--MySQL、微软SQL Server、Oracle database such as amount of job listings remains aboveMongoDB、Couchbase和CassandraThe amount of position.对NoSQLProfessional knowledge of the demand is still justSQLA small part of the skill market.

[In a timely manner to understand the latest development of cloud computing.订阅InfoWorld All Things Cloud新闻通讯] .

合并SQL和NoSQL

我们可以预期,随着时间的推移,SQL和NoSQLSome differences between system will disappear.现在已经有许多SQL数据库接受JSONDocument as a native data types,And can be conducted on the data query.Some database even had toJSONData the constraints of local method,Therefore the treatment of it with the traditional as well as the data row and column strictly.

另一方面,NoSQLDatabase not only increased the similarSQL的查询语言,Also added traditionalSQLOther functions of the database,比如MongoDB的ACID属性.

One possible path is,Future generations of future versions of the database and the current database system will cross the paradigm,同时提供SQL和NoSQL功能,有助于Make the database world no longer fragmented.例如,微软的Azure Cosmos DBUnder the hood using a set of primitives,Interchangeable reproduction of the two systems behave.谷歌云Spanner将SQLAnd the strong consistency andNoSQLCombination of horizontal scalability of the system.

不过,纯SQL和纯NoSQLSystem for many years in the future will have their place.In the design flexibility、Strong horizontal scalability and high availability than read consistency and otherSQLCommon database security measures more important under the condition of,可以考虑使用NoSQL.对于许多应用来说,These security measures is well worth to exchangeNoSQL提供的东西.

相关的.

Serdar Yegulalp是InfoWorld的高级作家,专注于机器学习、容器化、devops、Python生态系统和定期评论.

关注

Copyright 2022 IDG Communications, Inc.

如何选择一个低代码开发平台

原网站

版权声明
本文为[DebugUsery]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/214/202208020738008898.html