什么是nosql数据库_NoSQL数据库的基础-为什么我们需要它们

什么是nosql数据库

by Nandhini Saravanan

通过Nandhini Saravanan

NoSQL数据库的基础-为什么我们需要它们 (The basics of NoSQL databases — and why we need them)

NoSQL世界初学者指南 (A beginner’s guide to the NoSQL world)

Organizing data is a very difficult task. When we say organise, we are actually categorising stuff depending on its type and function.

组织数据是一项非常困难的任务。 当我们说“组织”时,实际上是根据事物的类型和功能对其进行分类。

One option is RDBMS is like an Excel Sheet — you categorise data in the form of tables. You can form relationships between the tables.

一种选择是RDBMS就像Excel工作表一样-您以表的形式对数据进行分类。 您可以在表之间形成关系。

A query questions the database, which gives you a relevant answer in return. This querying language is SQL or Structured Query Language.

查询会询问数据库,从而为您提供相关的答案。 该查询语言是SQL结构化查询语言。

For example,

例如,

select * from Employee_Data;

selects all the Employee Data from the Employee_Data table.

从Employee_Data表中选择所有Employee数据。

Relational databases follow a schema, a detailed blueprint of how your tables work.

关系数据库遵循模式 ,即表工作方式的详细蓝图。

You use Amazon, Facebook and so many networking applications. They release updates, add new functionalities and even extra modules. So how does one change the schema each time? Isn’t it time consuming for such huge companies to devote their time and labour to changing the schema?

您使用Amazon,Facebook和许多网络应用程序。 他们发布更新,添加新功能,甚至添加额外的模块。 那么,每次如何更改架构? 如此庞大的公司将时间和精力投入到更改架构上是否很耗时?

This is where SQL could not work.

这是SQL无法工作的地方

RDBMS的缺点 (The Cons of RDBMS)

Relational databases aren’t as bad as people portray these days. They are still in use by plenty of organisations. The introduction of NoSQL into the picture is to fill up the spaces where RDBMS can’t be of use anymore.

关系数据库并不像人们现在描绘的那样糟糕。 许多组织仍在使用它们。 NoSQL的引入是为了填补RDBMS不再使用的空间。

I am going to show you examples so that you have a clear understanding.

我将向您展示示例,以便您清楚地理解。

1. RDBMS无法处理“数据种类”。 (1. RDBMS can not handle ‘Data Variety’.)

The amount of unstructured data continues to increase yearly and managing it is hard. RDBMS can’t force all types of data under a unified schema of tables.

非结构化数据的数量逐年增加,并且难以管理。 RDBMS不能在统一的表模式下强制所有类型的数据。

Data Silos are also a problem for developers.

数据孤岛也是开发人员的问题。

According to Tech Target, a data silo is a repository of data that remains under the control of one department. It is isolated from the rest of the organisation.

根据Tech Target的说法, 数据孤岛是一个数据存储库,仍在一个部门的控制之下。 它与组织的其他部分隔离。

This means that when more silos exist for the same data, their contents are likely to differ. It creates confusion on which repository represents the most up-to-date version.

这意味着当相同数据存在更多孤岛时,它们的内容可能会有所不同。 它使哪个存储库代表最新版本令人困惑。

The increase of data from the year 2013 to 2020 is visible in the image below.

下图显示了2013年至2020年数据的增长。

About 44 Zeta bytes of data will be generated in the year 2020.
到2020年,将生成约44 Zeta字节的数据。

Handling such diverse data which aren’t related to each other could be much harder in RDBMS.

在RDBMS中,处理彼此不相关的各种数据可能会更加困难。

Example: It is difficult to store the details of a patient, who has varying body conditions. Categorisation of such diverse data is difficult in RDBMS.

示例:难以存储身体状况各异的患者的详细信息。 在RDBMS中,很难对这些多样化的数据进行分类。

2.难以更改表和关系。 (2. Difficult to change tables and relationships.)

Alteration of the relationships between tables or addition of a new table could affect the existing relations. This means changing the schema.

更改表之间的关系或添加新表可能会影响现有关系。 这意味着更改架构。

Change of the schema would be like eliminating the existing one and devising a new schema.

模式的更改就像消除现有模式并设计新的模式一样。

Addition of a new functionality would need all the elements to support the new structure. Change is inevitable.

添加新功能将需要所有元素来支持新结构。 变化是不可避免的。

Example: Each extra column needs all the prior rows to have values for that column. Whereas in Cassandra (a NoSQL database), you can add a column to specific row partitions.

示例:每个额外的列都需要所有先前的行才能具有该列的值。 而在Cassandra (NoSQL数据库)中,您可以将列添加到特定的行分区。

3. RDBMS遵循数据库的ACID属性。 (3. RDBMS follow the ACID properties of the database.)

The ACID properties of a database are Atomicity, Consistency, Isolation and Durability. ‌

数据库的ACID属性是原子性,一致性,隔离性和持久性。 ‌

Atomicity — An “all or nothing” approach. If any statement in the transaction fails, the entire transaction is rolled back.

原子性 -一种“全有或全无”的方法。 如果事务中的任何语句失败,则会回滚整个事务。

Consistency — The transaction must meet all protocols defined by the system. No half completed transactions.

一致性-事务必须满足系统定义的所有协议。 没有一半完成交易。

Isolation — No transaction has access to any other transaction that is in an intermediate or unfinished state. Each transaction is independent.

隔离-没有事务可以访问处于中间状态或未完成状态的任何其他事务。 每笔交易都是独立的。

Durability — Ensures that once a transaction commits to the database, it is preserved through the use of backups and transaction logs.

持久性 -确保一旦事务提交到数据库,就可以通过使用备份和事务日志来保留它。

The ACID properties aren’t flexible.

ACID属性不灵活。

For example, RDBMS follows Normalization or a single point of truth concept. For every change you make, you should ensure strict ACID properties. The entity integrity and referential integrity rules also apply.

例如,RDBMS遵循规范化单真点概念。 对于您进行的每项更改,都应确保使用严格的ACID属性。 实体完整性引用完整性规则也适用。

CAP定理 (The CAP Theorem)

According to Wikipedia, the CAP theorem (Brewer’s theorem) states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees:

根据Wikipedia的说法, CAP定理 (布鲁尔定理)指出,分布式数据存储不可能同时提供以下三个保证中的两个以上

Consistency: Like the C in ACID.

一致性:就像ACID中的C。

Availability: ‌Resources should be always available. There should be a non error response.

可用性 :‌资源应始终可用。 应该有一个非错误响应。

Partition tolerance: No single point (or node) of failure.

分区容限 :没有单一故障点(或节点)。

It is difficult to achieve all the three conditions. One must compromise between the three.

这三个条件很难实现。 必须在三者之间妥协。

BASE进行救援! (BASE to the rescue!)

‌NoSQL relies upon a softer model known as the BASE model. BASE (Basically Available, Soft state, Eventual consistency).

SQLNoSQL依赖于称为BASE模型的较软模型。 BASE(B asically vailable,S经常状态,E ventual一致性)。

Basically Available: Guarantees the availability of the data . There will be a response to any request (can be failure too).

基本上可用:保证数据的可用性。 任何请求都会有响应(也可能是失败的)。

Soft state: The state of the system could change over time.

软状态 :系统状态可能会随时间变化。

Eventual consistency: The system will eventually become consistent once it stops receiving input.

最终的一致性:一旦停止接收输入,系统最终将变得一致。

NoSQL databases give up the A, C and/or D requirements, and in return they improve scalability.

NoSQL数据库放弃了A,C和/或D要求,因此,它们提高了可伸缩性。

NoSQL (NoSQL)

This is when NoSQL came to the rescue.‌ It is “Not Only SQL” or “Non-relational” databases.

这是NoSQL抢救的时刻。‌它是“ 不仅仅是SQL”或“非关系”数据库。

Characteristics of NoSQL:

NoSQL的特点:

  • Schema free

    无架构
  • Eventually consistent (as in the BASE property)

    最终保持一致(如BASE属性中所示)
  • Replication of data stores to avoid Single Point of Failure.

    复制数据存储以避免单点故障。
  • Can handle Data variety and huge amounts of data.

    可以处理各种数据和大量数据。

NoSQL数据库的类型 (Types of NoSQL databases)

NoSQL databases fall into four main categories:

NoSQL数据库分为四个主要类别:

Key value Stores — Riak, Voldemort, and Redis

关键值商店 -Riak,Voldemort和Redis

Wide Column Stores — Cassandra and HBase.

宽列存储 -Cassandra和HBase。

Document databases — MongoDB

文档数据库— MongoDB

Graph databases — Neo4J and HyperGraphDB.

图形数据库 -Neo4J和HyperGraphDB。

The words to the right hand side are examples of the types of NoSQL database types.

右边的单词是NoSQL数据库类型的示例。

1. 关键值存储 (1. Key Value Stores)

A key value store uses a hash table in which there exists a unique key and a pointer to a particular item of data.

密钥值存储区使用哈希表,哈希表中存在唯一的密钥指向特定数据项的指针

Imagine key value stores to be like a phone directory where the names of the individual and their numbers are mapped together.

想象一下,键值存储就像一个电话目录,其中个人的名字和他们的号码映射在一起。

Key value stores have no default query language. You retrieve data using get, put, and delete commands. This is the reason it has high performance.

键值存储没有默认查询语言。 您可以使用get,put和delete命令检索数据。 这就是它具有高性能的原因

Applications: Useful for storage of Comments and Session information. ‌Pinterest uses Redis to store lists of users, followers, unfollowers, boards.

应用程序 :对于存储评论和会话信息有用。 interestPinterest使用Redis存储用户,关注者,取消关注者,董事会的列表。

2.宽列存储 (2. Wide column stores)

In a column store database, the columns in each row are contained within that row.

在列存储数据库中,每一行中的列都包含在该行中。

Each column family is a container of rows in an RDBMS table. The key identifies the row consisting of multiple columns.

每个列族都是RDBMS表中行的容器。 标识包含多列的行。

Rows do not need to have the same number of columns. Columns can be added to any row at any time without having to add it to other rows. It is a partitioned row store.

行不必具有相同的列数。 可以随时将列添加到任何行,而不必将其添加到其他行。 它是一个分区的行存储。

列式数据库如何存储数据? (How does a columnar database store data?)

Applications: Spotify uses Cassandra to store user profile attributes and metadata.

应用程序Spotify使用Cassandra存储用户配置文件属性和元数据。

3.文档数据库 (3. Document Databases)

‌Document stores uses JSON, XML, or BSON (binary encoding of JSON) documents to store data.

stores文档存储使用JSON,XML或BSON(JSON的二进制编码)文档存储数据。

It is like a key-value database, but a document store consists of semi-structured data.

它就像一个键值数据库,但是文档存储由半结构化数据组成

A single document is to store records and its data.

单个文档将存储记录及其数据。

‌It does not support relations or joins.

‌它不支持关系或联接。

If we want to store the customer details and their orders, we can use document stores to do it.

如果我们要存储客户详细信息及其订单,则可以使用文档存储来进行。

Applications: ‌SEGA uses MongoDB for handling 11 million in-game accounts built on MongoDB.

应用范围: SEGA 使用MongoDB处理在MongoDB上构建的1100万个游戏帐户。

4.图形数据库 (4. Graph databases)

‌Nodes and relationships are the essential constituents of graph databases. A node represents an entity. A relationship represents how two nodes are associated.

节点和关系是图形数据库的基本组成部分。 节点代表实体。 关系表示两个节点如何关联。

‌In RDBMS, adding another relation results in a lot of schema changes.

R在RDBMS中,添加另一个关系会导致很多模式更改。

Graph database requires only storing data once (nodes). The different types of relationships (edges) are specified to the stored data.

图形数据库只需要存储一次数据(节点)。 对存储的数据指定了不同类型的关系(边)。

The relationships between the nodes are predetermined, that is, it is not determined at query time.

节点之间的关系是预先确定的,即在查询时未确定。

Traversing persisted relationships are faster.

遍历持久关系更快。

It is difficult to change a relation between two nodes. It would result in regressive changes in the database.

很难更改两个节点之间的关系。 这将导致数据库中的回归更改。

Example: This image is how MySQL works where it has to perform many operations to find a correct result for Alice.

示例 :此图像是MySQL如何工作的地方,它必须执行许多操作才能为Alice找到正确的结果。

A graph database, which predetermines relationships.

图形数据库 ,其中预先确定的关系。

This is some of the basic information you will need to start exploring NoSQL. New databases are being invented for specific uses.

这是开始探索NoSQL所需的一些基本信息。 正在为特定用途发明新的数据库。

Learn the type of data your application generates, and then it is easy to choose the right database.

了解您的应用程序生成的数据类型,然后轻松选择合适的数据库。

我写有关“生命教训,编码和技术”的故事。 要了解更多信息,请在TwitterMedium上关注我 (I write stories on Life Lessons, Coding and Technology. To read more, follow me on Twitter and Medium.)

翻译自: https://www.freecodecamp.org/news/nosql-databases-5f6639ed9574/

什么是nosql数据库

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值