SQL NoSQL 的用例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2875432/
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
Use cases for NoSQL
提问by robjmills
NoSQL has been getting a lot of attention in our industry recently. I'm really interested in what peoples thoughts are on the best use-cases for its use over relational database storage. What should trigger a developer into thinking that particular datasets are more suited to a NoSQL solution. I'm particularly interested in MongoDBand CouchDBas they seem to be getting the most coverage with regard to PHP development and that is my focus.
NoSQL 最近在我们的行业中受到了很多关注。我真的很感兴趣人们的想法是关于它在关系数据库存储上使用的最佳用例。什么应该触发开发人员认为特定数据集更适合 NoSQL 解决方案。我对MongoDB和CouchDB尤其感兴趣,因为它们似乎在 PHP 开发方面的报道最多,这也是我的重点。
采纳答案by robjmills
Some great use-cases - for MongoDB anyway - are mentioned on the MongoDB site. The examples given are real-time analytics, Logging and Full Text search. These articles are all well worth a read http://www.mongodb.com/use-cases
MongoDB 站点上提到了一些很棒的用例 - 无论如何都适用于 MongoDB。给出的示例是实时分析、日志记录和全文搜索。这些文章都值得一读http://www.mongodb.com/use-cases
There's also a great write-up on which NoSQL database is best suited to which type of project: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
关于 NoSQL 数据库最适合哪种类型的项目,还有一篇很棒的文章:http: //kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
回答by spacemonkey
Just promise yourself that you will never try to map a relational data model to a NoSQL database like MongoDB or CouchDB... This is the most common mistake developers make when evaluating emerging tech.
向自己保证,您永远不会尝试将关系数据模型映射到像 MongoDB 或 CouchDB 这样的 NoSQL 数据库……这是开发人员在评估新兴技术时最常犯的错误。
That approach is analogous to taking a car and trying to use it to pull your cart down the road like a horse.
这种方法类似于驾驶一辆车并试图用它像马一样把你的车拉下马路。
It's a natural reaction due to everyone's experience of course, but the real value in using a document database is being able to simplify your datamodel and minimize your suffering as a developer. Your codebase will shrink, your bugs will be fewer and easier to find, performance is going to be awesome, and scale will be much simpler.
当然,由于每个人的经验,这是一种自然的反应,但使用文档数据库的真正价值在于能够简化您的数据模型并最大程度地减少您作为开发人员的痛苦。你的代码库会缩小,你的错误会更少,更容易找到,性能会很棒,规模也会更简单。
As a Joomla founder I'm biased :-) but coming from the CMS space, something like MongoDB is a silver bullet as content maps very naturally to document systems.
作为 Joomla 的创始人,我有偏见 :-) 但来自 CMS 领域,像 MongoDB 这样的东西是一个灵丹妙药,因为内容非常自然地映射到文档系统。
Another great case for MongoDB is real-time analytics, as MongoDB has very strong performance and scale particularly regarding concurrency. There are case studies at the MongoDB.org website that demonstrate those attributes.
MongoDB 的另一个重要案例是实时分析,因为 MongoDB 具有非常强大的性能和可扩展性,尤其是在并发方面。MongoDB.org 网站上的案例研究展示了这些属性。
I agree with the notion that each database has its own aims and use cases; take the purpose of each database for evaluation accordingly.
我同意每个数据库都有自己的目标和用例的观点;对每个数据库的目的进行相应的评估。
回答by kishkash
I'd suggest this article by Rick Cattell about miscellaneous data stores (a.k.a. NoSQL), their differences and some of their use-cases: http://www.cattell.net/datastores/index.html
我建议 Rick Cattell 撰写的这篇关于杂项数据存储(又名 NoSQL)、它们的差异和一些用例的文章:http: //www.cattell.net/datastores/index.html
回答by Moppo
I have been using NoSQL DBs for a while now, and this is my contribute to the topic:
我已经使用 NoSQL DB 有一段时间了,这是我对该主题的贡献:
A great use casefor a NoSQL database is an application for statisticsand / or reports generation, expecially when data is provided from a third party source.
NoSQL 数据库的一个很好的用例是用于统计和/或报告生成的应用程序,特别是当数据从第三方来源提供时。
In a situation like that a NoSQL database can be a great choice
在这种情况下,NoSQL 数据库可能是一个不错的选择
Let's consider, for example, MongoDB:
例如,让我们考虑MongoDB:
Once you have your data in JSON, ( it could come from a third party API, or be exported from an sql-application) in MongoDBis pretty strightforward to import
and updatethe JSON datain the database; for example using the command-line mongoimport
utility
一旦你拥有 JSON 格式的数据,(它可能来自第三方 API,或者从 sql 应用程序导出)在MongoDB中导入和更新数据库中的 JSON数据非常简单;例如使用命令行mongoimport
实用程序
At this point is very simple to build dynamic querieswith filtering and grouping, that well fit with this kind of application.
此时,通过过滤和分组构建动态查询非常简单,非常适合此类应用程序。
For example, using the Aggregation Framework:
例如,使用聚合框架:
$pipeline = [];
//filter by date
$pipeline[] = [ '$match' => [ 'created_at' => [ '$gte' => $starDate, '$lte' => $endDate ] ] ];
//if we want to filter by a specific field, we add the filter to the pipeline array
if( $filters->isFilterByField() )
$pipeline[] = [ '$match' => [ 'field' => $fieldValue ] ];
//group the results by date and get the count
$pipeline[] = [ '$group' => [ '_id' => '$created_at', 'num_elements' => [ '$sum' => 1 ] ] ];
return $collection->aggretate( $pipeline );
I'd like to point up the easinesswith which we can dinamically add/remove filtersusing php data structures and avoiding tedious string concatenation to build up our queries. With this approach adding/removing filters dinamycally is as easy as adding / removing elements from an array
我想指出了容易使我们可以dinamically添加/删除过滤器使用PHP数据结构,避免繁琐的字符串连接来建立我们的查询。使用这种方法添加/删除过滤器就像从数组中添加/删除元素一样简单
Another great benefit comes from the fact that a solution like this is likely to be fasterthan using a relational database, where we have to make joins with different tables to get all the data we need
另一个很大的好处来自这样一个事实,即像这样的解决方案可能比使用关系数据库更快,在关系数据库中我们必须与不同的表建立连接以获得我们需要的所有数据。
Besides, this use case is optimal because avoids all the principal limitsof a NoSQL database:
此外,这个用例是最佳的,因为它避免了 NoSQL 数据库的所有主要限制:
Lack of transactions:The application doesn't perform writes but only reads, so we don't need transactions at all
Lack of joins between tables:We don't need joins, as we can use redundancyto store our denormalized datain the collections. As we only read data, we don't need to be worried about synchronizing denormalized data among updates.
缺少事务:应用程序不执行写入而只执行读取,因此我们根本不需要事务
表之间缺乏连接:我们不需要连接,因为我们可以使用冗余将非规范化数据存储在集合中。由于我们只读取数据,因此无需担心在更新之间同步非规范化数据。
This way we can focus on storing the datawith redundancy in a manner that well fits to our queries, that will be focus on single collections.
通过这种方式,我们可以专注于以非常适合我们的查询的方式存储具有冗余的数据,这将专注于单个集合。
I'm just writing this because had i read something like that some times ago, it would have been saved me some time to make researches
我写这个是因为如果我以前读过类似的东西,它会为我节省一些时间进行研究
Hope it will be useful to someone
希望它对某人有用
回答by ysimonson
What I like about NoSQL has nothing to do with performance and everything to do with usability. Document stores are just easier to work with when your atomic data units are document-like, because it's trivial to serialize to and from objects. It's just more fun, and that's an important factor for personal or side projects.
我喜欢 NoSQL 的地方与性能无关,而与可用性有关。当您的原子数据单元类似于文档时,文档存储更容易使用,因为在对象之间进行序列化是微不足道的。它只是更有趣,这是个人或副项目的重要因素。
回答by user3631881
I strongly recommend this talk by Martin Fowler:
我强烈推荐 Martin Fowler 的这个演讲:
https://www.youtube.com/watch?v=qI_g07C_Q5I
https://www.youtube.com/watch?v=qI_g07C_Q5I
ABSTRACT:Martin gives a rapid introduction to NoSQL databases: where they came from, the nature of the data models they use, and the different way you have to think about consistency. From this he outlines what kinds of circumstances you should consider using them, why they will not make relational databases obsolete, and the important consequence of polyglot persistence.
摘要:Martin 快速介绍了 NoSQL 数据库:它们来自哪里,它们使用的数据模型的性质,以及您必须以不同的方式考虑一致性。据此,他概述了您应该考虑在何种情况下使用它们,为什么它们不会使关系数据库过时,以及多语言持久性的重要后果。
It draws a nice picture of what NoSQL is, the different categories and the things everyone has to understand when coming from relational databases world. Regards.
它很好地描绘了 NoSQL 是什么、不同的类别以及每个人在来自关系数据库世界时必须理解的东西。问候。
回答by Ravindra babu
First you have to understand CAP (Consistency, Availability and Partitioning, where you have to pick-up two of three) theory and our Business use case. MongoDB satisfies Consistency and Partitioning & Couch DB satisifies Availability & Partitioning.
首先,您必须了解 CAP(一致性、可用性和分区,您必须选择三个中的两个)理论和我们的业务用例。MongoDB 满足一致性和分区,Couch DB 满足可用性和分区。
Edureka videos in youtube regarding NoSQL are some of the best video tutorials.
youtube 上关于 NoSQL 的 Edureka 视频是一些最好的视频教程。
https://www.youtube.com/watch?v=gJFG04Sy6NY
https://www.youtube.com/watch?v=gJFG04Sy6NY
https://www.youtube.com/watch?v=KSq6tMMXZ8s
https://www.youtube.com/watch?v=KSq6tMMXZ8s
https://www.youtube.com/watch?v=3z1KFA2qcSo
https://www.youtube.com/watch?v=3z1KFA2qcSo
Good presentations are available in slideshare.net
好的演示文稿可以在 slideshare.net 上找到
http://www.slideshare.net/EdurekaIN/no-sql-databases-35591065?qid=f1b9c095-6d70-4d0a-91da-1df664c4f389&v=qf1&b=&from_search=3(This presentation supports video tutorial in youtube)
http://www.slideshare.net/EdurekaIN/no-sql-databases-35591065?qid=f1b9c095-6d70-4d0a-91da-1df664c4f389&v=qf1&b=&from_search=3(本演示支持youtube视频教程)
回答by metdos
For some use cases you need, especially for analytic queries you can run SQL queries on MongoDB with this wrapperfrom Postgres.
对于您需要的某些用例,特别是对于分析查询,您可以使用Postgres 的这个包装器在 MongoDB 上运行 SQL 查询。
回答by Austin Gonyou
Because there are now many more NoSQL databases on the market than ever before, I suggest having a look at the Gartner Magic Quadrant if you're looking for a database that will also be great for enterprise applications based on support, expandability, management, and cost.
因为现在市场上的 NoSQL 数据库比以往任何时候都多,如果您正在寻找一种基于支持、可扩展性、管理和成本。
http://www.gartner.com/technology/reprints.do?id=1-23A415Q&ct=141020&st=sb
http://www.gartner.com/technology/reprints.do?id=1-23A415Q&ct=141020&st=sb
I would like to suggest Couchbase to anyone who's not tried it yet, but not based on the version that is shown in the report (2.5.1) because it is nearly 2 revisions behind where CB Server is today, nearing release of 4.0 in 2H15.
我想向任何还没有尝试过 Couchbase 的人推荐 Couchbase,但不是基于报告中显示的版本 (2.5.1),因为它比今天的 CB Server 落后近 2 个修订版,接近 2H15 的 4.0 版本.
http://www.couchbase.com/coming-in-couchbase-server-4-0
http://www.couchbase.com/coming-in-couchbase-server-4-0
The other part about Couchbase as a vendor/product is that it is a multi-use type of DB. It can act as a pure K/V store, Document Oriented Database with multi-dimensional scaling, Memcached, cache-aside with persistence, and supports ANSI 92 compliant SQL with automatic joins, replication to DR clusters with the push of a button, and even has a mobile component built-in to the ecosystem.
关于 Couchbase 作为供应商/产品的另一部分是它是一种多用途类型的数据库。它可以充当纯 K/V 存储、具有多维扩展的面向文档的数据库、Memcached、具有持久性的缓存,并支持具有自动连接的符合 ANSI 92 的 SQL,只需按一下按钮即可复制到 DR 集群,以及甚至在生态系统中内置了一个移动组件。
If nothing else, it's worth checking out the latest benchmarks:
如果不出意外,值得查看最新的基准测试:
http://info.couchbase.com/Benchmark_MongoDB_VS_CouchbaseServer_HPW_BM.htmlhttp://info.couchbase.com/NoSQL-Technical-Comparison-Report.html
http://info.couchbase.com/Benchmark_MongoDB_VS_CouchbaseServer_HPW_BM.html http://info.couchbase.com/NoSQL-Technical-Comparison-Report.html