简体   繁体   English

哪种类型的情况适合使用关系数据库和NoSQL数据库?

[英]What types of situations are suited to use both a relational and NoSQL database?

This is not a NoSQL vs. SQL type question. 这不是NoSQL vs. SQL类型的问题。 I am interested in types of scenarios where one can use a combination of a RDBMS and NoSQL database and the use of the combination is well suited . 我对可以使用RDBMS和NoSQL数据库的组合的场景类型感兴趣,并且组合的使用非常适合 In general, I understand the "it depends" on the situation and task at hand, but my thinking is that there must be some general/common 1 situations where this combination is very useful. 一般情况下,我明白了“这取决于”手头上的形势和任务,但我的想法是,必须有一些普通/通用1分的情况下这样的组合是非常有用的。

Each of the above types of solutions have there own strengths and weaknesses - what I am after is situations/scenarios where the strengths of both can be fully exploited and utilised. 上述每种类型的解决方案都有自己的优点和缺点 - 我所追求的是可以充分利用和利用两者优势的情况/场景。

In my mind, one could be E-commerce. 在我看来,一个可能是电子商务。 Payments, transactions etc on a RDBMS (think ACID 2 ) and product information and catalogues in a NoSQL database. RDBMS上的付款,交易等(想想ACID 2 )以及NoSQL数据库中的产品信息和目录。 But, is it suitable? 但是,它适合吗?

Cross cutting concerns of an application eg. 应用的横切关注点,例如。 Logging is probably well suited for a NoSQL type solution as another example. 作为另一个例子,日志记录可能非常适合NoSQL类型的解决方案。

Alternatively, why would you not use both these types of technologies in combination? 或者,为什么不组合使用这两种技术?

Edit: Just to reiterate, I understand that that both SQL and NoSQL have their inherent advantages and disadvantages and that that certain types of situations are more suited to only one of the above data stores. 编辑:重申一下,我理解SQL和NoSQL都有其固有的优点和缺点,并且某些类型的情况更适合上述数据存储中的一个。

1 Iknow the giants like Facebook, Google etc probably use a combination of these, but in almost all most cases I don't think most SO members will ever work on such huge solutions. 1我知道Facebook,谷歌等巨头可能会使用这些巨头,但 几乎 在大多数情况下,我认为大多数SO成员都不会使用这些巨大的解决方案。 More typical day-to-day type stuff. 更典型的日常类型的东西。

2 RavenDB is a NoSQL solution that supports ACID transactions 2 RavenDB是一种支持ACID事务的NoSQL解决方案

NOSQL could possibly be used to replicate data from a SQL datastore. NOSQL可能用于从SQL数据存储区复制数据。 In this scenario i want to create documents from mobile SQLITE records, and rely on couch or mongo to replicate this to a nosql on the server. 在这种情况下,我想从移动SQLITE记录创建文档,并依赖couch或mongo将其复制到服务器上的nosql。 The server SQL can then process the incoming documents. 然后,服务器SQL可以处理传入的文档。

A good example could be any distributed data store being updated at multiple nodes simultaneously and needing to support potentially complex ad hoc queries. 一个很好的例子可能是任何分布式数据存储同时在多个节点上更新,并且需要支持可能复杂的即席查询。 Nodes would be "eventually consistent", which means any particular node might have gaps in its picture of the data at any point in time. 节点将“最终一致”,这意味着任何特定节点在任何时间点的数据图像中都可能存在间隙。

This suits an RDBMS well because the gaps can be handled very simply by "outer" joins between relations. 这很适合RDBMS,因为间隙可以通过关系之间的“外部”连接非常简单地处理。 The relational model should be a better fit for this than, say, a graph-based model because the graph model relies on navigational paths between different data elements. 关系模型应该比基于图形的模型更适合于此,因为图模型依赖于不同数据元素之间的导航路径。 If an element is missing then the graph is broken into two graphs and so any path-based query might be invalidated. 如果缺少某个元素,则该图形将分为两个图形,因此任何基于路径的查询都可能无效。 This problem doesn't exist in the relational model because relational databases are non-navigational - there are no structural "links" between data elements so the "shape" of queries against the data does not need to change just because data is missing. 关系模型中不存在此问题,因为关系数据库是非导航的 - 数据元素之间没有结构“链接”,因此针对数据的查询的“形状”不需要仅因为数据丢失而更改。

An obvious answer could be reporting as an example as to where one is more appropriate than the other in a simple application. 一个明显的答案可能是报告一个例子,在一个简单的应用程序中哪一个比另一个更合适。

For example, you might wish to use a document databae like RavenDB or Couch for your OLTP work, because it gives you the means to save your entities, and query those entities out into flattened projections across documents (single-query views). 例如,您可能希望为OLTP工作使用RavenDB或Couch等文档数据库,因为它为您提供了保存实体的方法,并将这些实体查询为跨文档的平面投影(单查询视图)。 (RavenDB more than CouchDB, but that's neither here nor there ;-)) (RavenDB比CouchDB更多,但这既不在这里也不在那里;-))

You could also use it for simple reporting, using Map/Reduce to give you some statistics for display on certain pages (popular products, tag clouds etc). 您还可以将它用于简单报告,使用Map / Reduce为您提供某些统计信息,以便在某些页面上显示(热门产品,标签云等)。

However, a lot of reporting systems are built to query relational stores, so you might want to replicate data into a reporting database. 但是,构建了许多报表系统来查询关系存储,因此您可能希望将数据复制到报表数据库中。

For example, in RavenDB, you have the option to take any index, and automatically replicate the data in that index into a relational store. 例如,在RavenDB中,您可以选择获取任何索引,并自动将该索引中的数据复制到关系存储中。

It makes sense because having the data in a relational format means you can do complex cross-document queries and integrate with existing reporting products - without getting in the way of the standard OLTP work or the document database design. 这是有道理的,因为以关系格式存储数据意味着您可以执行复杂的跨文档查询并与现有报告产品集成 - 而不会妨碍标准OLTP工作或文档数据库设计。

This is just one answer out of many, because there are other examples where one particular sort of data store is more suited towards a specific purpose, at the end of the day there is no getting away from that. 这只是众多问题中的一个答案,因为还有其他一些例子,其中一种特定类型的数据存储更适合于特定目的,在一天结束时,没有远离它。 (Unless you believe the VoltDB guys) (除非你相信VoltDB的人)

Unless you are operating at a scale where relational databases simply won't work, the big advantage of NoSQL is ease of development - things like not needing an ORM or database upgrade scripts. 除非您在关系数据库根本无法工作的规模下运行,否则NoSQL的一大优势是易于开发 - 例如不需要ORM或数据库升级脚本。 As soon as you start using SQL for one part of the system it takes very little additional effort to use it for other parts. 一旦开始在系统的一个部分使用SQL,将其用于其他部分只需要很少的额外工作。

In just about any project there will be components that are more suited to a particular type of data store. 在几乎任何项目中,都会有更适合特定类型数据存储的组件。 The important question is whether the difference is enough to justify the overhead of using multiple data stores. 重要的问题是差异是否足以证明使用多个数据存储的开销。 Generally that means a combination of scale, ad hoc reporting and data structures that don't map well to a relational database. 通常,这意味着规模,临时报告和数据结构的组合不能很好地映射到关系数据库。

It's not really a programming question but here is what I think. 这不是一个真正的编程问题,但这就是我的想法。

If you consider the CAP theorem http://en.wikipedia.org/wiki/CAP_theorem , you could assume that Relationnal Databases focus on CONSISTENCY and AVAILABILITY while NoSQL focus on AVAILABILITY and PARTITION TOLERENCE (with EVENTUAL CONSISTENCY). 如果考虑CAP定理http://en.wikipedia.org/wiki/CAP_theorem ,你可以假设Relationnal数据库集中在一致性和可用性,而NoSQL的专注于可用性和分区耐性(与最终一致性)。

If you espect the SQL query to be really consistent then you should consider using a RDBMS. 如果您认为SQL查询真的一致,那么您应该考虑使用RDBMS。 If it's not a pre-requisite, then you could use a NoSQL database. 如果它不是先决条件,那么您可以使用NoSQL数据库。

That's why most of the time, the best answer it to use both, taking advantages of both. 这就是为什么大多数时候,最好的答案是同时使用两者,兼顾两者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM