database 是否有任何符合 ACID 的 NoSQL 数据存储?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2608103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there any NoSQL data store that is ACID compliant?
回答by AJ.
I'll post this as an answer purely to support the conversation - Tim Mahy, nawroth, and CraigTPhave suggested viable databases. CouchDBwould be my preferred due to the use of Erlang, but there are others out there.
我纯粹是张贴此作为一个答案,支持对话-蒂姆·梅伊,nawroth和CraigTP建议可行的数据库。由于使用了Erlang,CouchDB将是我的首选,但还有其他的。
I'd say ACIDdoes not contradict or negate the concept of NoSQL... While there seems to be a trend following the opinion expressed by dove, I would argue the concepts are distinct.
我会说ACID并不矛盾或否定NoSQL的概念......虽然dove表达的观点似乎有一种趋势,但我认为这些概念是不同的。
NoSQLis fundamentally about simple key-value (e.g. Redis) or document-style schema (collected key-value pairs in a "document" model, e.g. MongoDB) as a direct alternative to the explicit schema in classical RDBMSs. It allows the developer to treat thingsasymmetrically, whereas traditional engines have enforced rigid same-nessacross the data model. The reason this is so interesting is because it provides a different way to deal with change, and for larger data sets it provides interesting opportunities to deal with volumes and performance.
NoSQL基本上是关于简单的键值(例如 Redis)或文档样式模式(在“文档”模型中收集键值对,例如 MongoDB)作为经典 RDBMS 中显式模式的直接替代方案。它允许开发人员不对称地处理事物,而传统引擎在整个数据模型中强制执行严格的相同性。之所以如此有趣,是因为它提供了一种不同的方式来处理变化,并且对于更大的数据集,它提供了处理容量和性能的有趣机会。
ACIDprovides principles governing how changes are applied to a database. In a very simplified way, it states (my own version):
ACID提供了控制如何将更改应用于数据库的原则。它以一种非常简化的方式说明(我自己的版本):
- (A) when you do something to change a database the change should work or fail as a whole
- (C) the database should remain consistent (this is a pretty broad topic)
- (I) if other things are going on at the same time they shouldn't be able to see things mid-update
- (D) if the system blows up (hardware or software) the database needs to be able to pick itself back up; and if it says it finished applying an update, it needs to be certain
- (A) 当你做一些改变数据库的事情时,改变应该作为一个整体起作用或失败
- (C) 数据库应该保持一致(这是一个相当广泛的话题)
- (I) 如果其他事情同时发生,他们应该看不到更新中的事情
- (D) 如果系统崩溃(硬件或软件),数据库需要能够自我恢复;如果它说它已完成应用更新,则需要确定
The conversation gets a little more excitable when it comes to the idea of propagation and constraints. Some RDBMS engines provide the ability to enforce constraints (e.g. foreign keys) which may have propagation elements (a la cascade). In simpler terms, one "thing" may have a relationship with another "thing" in the database, and if you change an attribute of one it may require the other be changed (updated, deleted, ... lots of options). NoSQLdatabases, being predominantly (at the moment) focused on high data volumes and high traffic, seem to be tackling the idea of distributed updates which take place within (from a consumer perspective) arbitrary time frames. This is basically a specialized form of replicationmanaged via transaction- so I would say that if a traditional distributed database can support ACID, so can a NoSQL database.
当谈到传播和约束的想法时,谈话变得更加激动人心。一些 RDBMS 引擎提供强制约束(例如外键)的能力,这些约束可能具有传播元素(a la cascade)。简单来说,一个“事物”可能与数据库中的另一个“事物”有关系,如果您更改其中一个的属性,则可能需要更改另一个(更新、删除……很多选项)。NoSQL数据库(目前)主要专注于高数据量和高流量,似乎正在解决在(从消费者角度)任意时间范围内发生的分布式更新的想法。这基本上是一种特殊的复制形式,通过管理事务- 所以我会说,如果传统的分布式数据库可以支持 ACID,那么 NoSQL 数据库也可以。
Some resources for further reading:
一些进一步阅读的资源:
回答by CraigTP
UPDATE (27 July 2012):Link to Wikipedia article has been updated to reflect the version of the article that was current when this answer was posted. Please note that the current Wikipedia articlehas been extensively revised!
更新(2012 年 7 月 27 日):维基百科文章的链接已更新,以反映发布此答案时当前文章的版本。请注意,当前的维基百科文章已被广泛修订!
Well, according to an older version of a Wikipedia article on NoSQL:
好吧,根据维基百科上 NoSQL 文章的旧版本:
NoSQL is a movement promoting a loosely defined class of non-relational data stores that break with a long history of relational databases and ACID guarantees.
NoSQL 是一种推动松散定义的非关系数据存储类的运动,这些存储打破了关系数据库和 ACID 保证的悠久历史。
and also:
并且:
The name was an attempt to describe the emergence of a growing number of non-relational, distributed data stores that often did not attempt to provide ACID guarantees.
该名称试图描述越来越多的非关系分布式数据存储的出现,这些存储通常不尝试提供 ACID 保证。
and
和
NoSQL systems often provide weak consistency guarantees such as eventual consistency and transactions restricted to single data items, even though one can impose full ACID guarantees by adding a supplementary middleware layer.
NoSQL 系统通常提供弱一致性保证,例如最终一致性和仅限于单个数据项的事务,即使可以通过添加补充中间件层来强加完整的 ACID 保证。
So, in a nutshell, I'd say that one of the main benefits of a "NoSQL" data store is its distinct lackof ACIDproperties. Furthermore, IMHO, the more one tries to implement and enforce ACIDproperties, the further away from the "spirit" of a "NoSQL" data store you get, and the closer to a "true" RDBMSyou get (relatively speaking, of course).
因此,概括地说,我会说的“NoSQL的”数据存储的主要好处之一是它的独特缺乏的ACID属性。此外,恕我直言,越是尝试实现和强制执行ACID属性,您获得的“NoSQL”数据存储的“精神”就越远,您获得的“真正” RDBMS就越接近(当然,相对而言, )。
However, all that said, "NoSQL" is a very vague term and is open to individual interpretations, and depends heavily upon just how much of a purist viewpoint you have. For example, most modern-day RDBMS systems don't actually adhere to allof Edgar F. Codd's 12 rulesof his relation model!
然而,总而言之,“NoSQL”是一个非常模糊的术语,可以接受个人解释,并且在很大程度上取决于您拥有多少纯粹的观点。例如,最现代的RDBMS系统实际上并不坚持所有的埃德加·科德的12条规则他的关系模型!
Taking a pragmatic approach, it would appear that Apache's CouchDBcomes closest to embodying both ACID-compliance whilst retaining loosely-coupled, non-relational "NoSQL" mentality.
采取务实的方法,似乎 Apache 的CouchDB最接近体现 ACID 合规性,同时保留松散耦合、非关系“NoSQL”的心态。
回答by Arnaud Bouchez
Please ensure you read the Martin Fowler introduction about NoSQL databases. And the corresponding video.
请务必阅读 Martin Fowler 关于 NoSQL 数据库的介绍。以及相应的视频。
First of all, we can distinguish two types of NoSQL databases:
首先,我们可以区分两种类型的 NoSQL 数据库:
- Aggregate-oriented databases;
- Graph-oriented databases (e.g. Neo4J).
- 面向聚合的数据库;
- 面向图形的数据库(例如 Neo4J)。
By design, most Graph-oriented databases are ACID!
按照设计,大多数面向图的数据库都是 ACID!
Then, what about the other types?
那么,其他类型呢?
In Aggregate-oriented databases, we can put three sub-types:
在面向聚合的数据库中,我们可以放置三个子类型:
- Document-based NoSQL databases (e.g. MongoDB, CouchDB);
- Key/Value NoSQL databases (e.g. Redis);
- Column family NoSQL databases (e.g. Hibase, Cassandra).
- 基于文档的 NoSQL 数据库(例如 MongoDB、CouchDB);
- 键/值 NoSQL 数据库(例如 Redis);
- 列族 NoSQL 数据库(例如 Hibase、Cassandra)。
What we call an Aggregatehere, is what Eric Evans defined in its Domain-Driven Designas a self-sufficient of Entities and Value-Objects in a given Bounded Context.
我们在这里所说的聚合是 Eric Evans 在其领域驱动设计中定义的给定限界上下文中实体和值对象的自给自足。
As a consequence, an aggregate is a collection of data that we interact with as a unit. Aggregates form the boundaries for ACID operations with the database. (Martin Fowler)
因此,聚合是我们作为一个单元进行交互的数据集合。聚合形成了 ACID 操作与数据库的边界。(马丁福勒)
So, at Aggregate level, we can say that most NoSQL databases can be as safe as ACID RDBMS, with the proper settings. Of source, if you tune your server for the best speed, you may come into something non ACID. But replication will help.
因此,在聚合级别,我们可以说大多数 NoSQL 数据库都可以像 ACID RDBMS 一样安全,只要进行适当的设置。当然,如果您将服务器调整为最佳速度,您可能会遇到非 ACID 的问题。但是复制会有所帮助。
My main point is that you have to use NoSQL databases as they are, not as a (cheap) alternative to RDBMS. I have seen too much projects abusing of relations between documents. This can't be ACID. If you stay at document level, i.e. at Aggregate boundaries, you do not need any transaction. And your data will be as safe as with an ACID database, even if it not truly ACID, since you do not need those transactions! If you need transactions and update several "documents" at once, you are not in the NoSQL world any more - so use a RDBMS engine instead!
我的主要观点是您必须按原样使用 NoSQL 数据库,而不是作为 RDBMS 的(廉价)替代方案。我见过太多项目滥用文档之间的关系。这不可能是 ACID。如果您停留在文档级别,即在聚合边界,您不需要任何事务。您的数据将与 ACID 数据库一样安全,即使它不是真正的 ACID,因为您不需要这些事务!如果您需要事务并一次更新多个“文档”,那么您就不再处于 NoSQL 世界中了——所以改用 RDBMS 引擎吧!
some 2019 update: Starting in version 4.0, for situations that require atomicity for updates to multiple documents or consistency between reads to multiple documents, MongoDB provides multi-document transactions for replica sets.
一些 2019 更新:从 4.0 版本开始,对于需要原子性更新多个文档或读取多个文档之间的一致性的情况,MongoDB为副本集提供了多文档事务。
回答by Ken Tindell
FoundationDB is ACID compliant:
FoundationDB 符合 ACID:
It has proper transactions, so you can update multiple disparate data items in an ACID fashion. This is used as the foundation for maintaining indexes at a higher layer.
它具有适当的事务,因此您可以以 ACID 方式更新多个不同的数据项。这是在更高层维护索引的基础。
回答by CoreDev
In this question someone must mention OrientDB: OrientDB is a NoSQL database, one of the few, that support fully ACID transactions. ACID is not only for RDBMS because it's not part of the Relational algebra. So it IS possible to have a NoSQL database that support ACID.
在这个问题中,有人必须提到OrientDB:OrientDB 是一个 NoSQL 数据库,是少数支持完全 ACID 事务的数据库之一。ACID 不仅适用于 RDBMS,因为它不是关系代数的一部分。所以有可能有一个支持 ACID 的 NoSQL 数据库。
This feature is the one I miss the most in MongoDB
这个功能是我在 MongoDB 中最怀念的功能
回答by Kevin Cox
ACID and NoSQL are completely orthogonal. One does not imply the other.
ACID 和 NoSQL 是完全正交的。一个并不意味着另一个。
I have a notebook on my desk, I use it to keep notes on things that I still have to do. This notebook is a NoSQL database. I query it using a linear search with a "page cache" so I don't always have to search every page. It is also ACID compliant as I ensure that I only write one thing at a time and never while I am reading it.
我的桌子上有一个笔记本,我用它来记录我仍然必须做的事情。这个笔记本是一个 NoSQL 数据库。我使用带有“页面缓存”的线性搜索来查询它,因此我不必总是搜索每个页面。它也是符合 ACID 的,因为我确保一次只写一件事,而不是在我阅读它的时候。
NoSQL simply means that it isn't SQL. Many people get confused and think it means highly-scaleable-wild-west-super-fast-storage. It doesn't. It doesn't mean key-value store, or eventual consistency. All it means is "not SQL", there are a lot of databases in this planet and most of them are not SQL[citation needed].
NoSQL 只是意味着它不是 SQL。许多人感到困惑,并认为这意味着高度可扩展的狂野西部超快速存储。它没有。这并不意味着键值存储或最终一致性。这意味着“不是 SQL”,这个星球上有很多数据库,其中大部分都不是 SQL [需要引用]。
You can find many examples in the other answers so I need not list them here, but there are non-SQL databases with ACID compliance for various operations, some are only ACID for single object writes while some guarantee far more. Each database is different.
您可以在其他答案中找到许多示例,因此我无需在此处列出它们,但是存在针对各种操作具有 ACID 合规性的非 SQL 数据库,有些仅为单个对象写入的 ACID,而有些则保证更多。每个数据库都不同。
回答by Michael Borgwardt
"NoSQL" is not a well-defined term. It's a very vague concept. As such, it's not even possible to say what is and what is not a "NoSQL" product. Not nearly all of the products typcially branded with the label are key-value stores.
“NoSQL”不是一个定义明确的术语。这是一个非常模糊的概念。因此,甚至不可能说什么是“NoSQL”产品,什么不是“NoSQL”产品。并非几乎所有通常贴有标签的产品都是键值商店。
回答by dscape
Yes, MarkLogic Server is a NoSQL solution (document database I like to call it) that works with ACID transactions
是的,MarkLogic Server 是适用于 ACID 事务的 NoSQL 解决方案(我喜欢称之为文档数据库)
回答by Lennart Regebro
The grandfather of NoSQL: ZODB is ACID compliant. http://www.zodb.org/
NoSQL 之父:ZODB 符合 ACID。http://www.zodb.org/
However, it's Python only.
但是,它只是 Python。
回答by nawroth
If you are looking for an ACID compliant key/value store, there's Berkeley DB. Among graph databasesat least Neo4jand HyperGraphDBoffer ACID transactions (HyperGraphDB actually uses Berkeley DB for low-level storage at the moment).
如果您正在寻找符合 ACID 的键/值存储,则可以使用Berkeley DB。在图数据库中,至少Neo4j和HyperGraphDB提供 ACID 事务(HyperGraphDB 目前实际上使用 Berkeley DB 进行低级存储)。

