是什么让 Cassandra(以及一般的 NoSQL)成为 RDBMS 的更好解决方案? [英] What makes Cassandra (and NoSQL in general) a better solution to an RDBMS?

查看:21
本文介绍了是什么让 Cassandra(以及一般的 NoSQL)成为 RDBMS 的更好解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,NoSQL 现在是一个流行词,所以我一直在研究它.我还没有了解 ColumnFamilies 和 SuperColumns 等......但我一直在研究数据是如何映射的.

Well, NoSQL is a buzzword right now so I've been looking into it. I'm yet to get my head around ColumnFamilies and SuperColumns, etc... But I have been looking at how the data is mapped.

阅读这篇文章和其他文章后,似乎数据以类似 JSON 的格式映射.

After reading this article, and others, it seems the data is mapped in a JSON like format.

Users = {
    1: {
        username: "dave",
        password: "blahblah",
        dateReged: "1/1/1"
    },
    2: {
        username: "etc",
        password: "blahblah",
        dateReged: "2/1/1",
        comment: "this guy has a comment and dave doesns't"
    },
}

RDBMS 格式为:

Table name: "Users"

id | username | password | dateReged | comment
---+----------+----------+-----------+--------
 1 |  dave    | blahblah |  1/1/1    |
---+----------+----------+-----------+--------
 2 |  etc     | blahblah |  2/1/1    | this guy has a comment and dave doesn't

假设我理解正确并且我上面的例子是正确的,为什么我会选择 RDBMS 设计而不是 NoSQL 设计?就我个人而言,我更愿意使用 JSON 结构......这是否意味着我应该选择 NoSQL 而不是 MySQL?

Assuming I understand this correctly and my above examples are right, why would I choose the RDBMS design over the NoSQL design? Personally, I'd much rather work with the JSON structure... Does this mean I should choose NoSQL over, say, MySQL?

我想我想问的是我什么时候应该选择 NoSQL 而不是 RDBMS?"

I guess what I'm asking is "when should I choose NoSQL over RDBMS?"

顺便说一句,正如我所说的,我仍然没有完全理解如何实施 Cassandra 数据库.即,如何在新数据库中创建上述用户表?您可以指出的任何教程、文档等都会很棒.我的 google'ing 在从头开始"方面没有出现太多......

On a side note, as I've said, I'm still not fully understanding how to go about implementing a Cassandra database. Ie, how do I create the above Users table in a new database? Any tutorials, documentation, etc you could point to would be great. My google'ing hasn't turned up much in terms of 'starting from scratch'...

推荐答案

如果您是 google,那么您可能处于这样的境地:NoSQL 比 RDBMS 对您更容易.既然您不是,那么 RDBMS 为您提供的许多优势可能会有用.值得注意的是,在单个节点上,NoSQL 与 RDBMS 相比绝对没有优势.不过,与 NoSQL 相比,RDBMS 具有许多优势.它们是什么?

If you are google, then you might be in a position where a NoSQL would be easier on you than a RDBMS. Since you are not, the many advantages an RDBMS provides you will probably be of some use. Significantly, on a single node, NoSQL offers absolutely no advantages over RDBMSes. RDBMSes offer lots of advantages over NoSQL, though. what are they?

RDBMS 使用一些非常深奥的魔法来理解它拥有的数据以及您要求的数据,这样它就可以以最有效的方式返回该数据.如果您没有询问某个列,则 rdbms 不会浪费任何精力来检索它.如果您对在两个表中具有共同字段的行感兴趣(这是一个连接,顺便说一句),RDBMS 不必检查每一对行是否匹配,或者 NoSQL 数据库通常所做的只是给出你的一切,让你做检查.使用 RDBMS,您通常可以构建实际上关于"您正在使用的数据的查询,例如如果日期是星期二",并且您的索引支持它(如果您经常执行该查询,那么您将添加这样的index),您可以有效地获取这些行.

RDBMSes use some pretty deep magic to understand the data it owns, and the data you are asking for, in such a way that it can return that data in the most efficient manner possible. If you didn't ask about some column, the rdbms doesn't waste any effort retrieving it. If you are interested in rows that have fields in common across two tables, (this is a join, btw), the RDBMS doesn't have to check every single pair of rows for matches, or what a NoSQL db usually does is just give you everything and make you do the checking. with a RDBMS, you can usually construct queries that are actually 'about' the data you are using, like "if the date is a tuesday", and if your indexes support it (if you do that query alot then you would add such an index) you can get those rows efficiently.

RDBMS 很好还有另一个原因.事务在 RDBMS 上很容易,但在 NoSQL 数据库上要正确处理要困难得多.假设您正在实施一个博客引擎.假设帖子标题(出现在 URL 中)需要在所有帖子中都是唯一的.在 RDBMS 中,您可以轻松确保不会意外出错.对于 NoSQL 数据库,如果它确实支持某种事务完整性,它通常在分片级别,任何可能需要这种完整性的东西都必须在同一个分片上.由于任何一对用户都可能在同一时刻发帖,那么每个用户的帖子必须在同一个分片上才能获得相同的效果.那么,您根本无法从 NoSQL 中获得任何好处.

There is another reason why RDBMSes are nice. Transactions are easy on RDBMSes, but are much harder to get right on NoSQL databases. Supposing you are implementing a blogging engine. Suppose the post title (which appears in the URL) needs to be unique across all posts. In an RDBMS, you can easily be sure that you won't get this wrong accidentally. With a NoSQL database, if it does support some kind of transactional integrity, it's usually at the shard level, anything that could possibly require that kind of integrity must be on the same shard. since any pair of users could possibly be posting at the same moment, then every users' post must be on the same shard to get the same effect. Well, then you don't get any benefit at all from NoSQL.

这篇关于是什么让 Cassandra(以及一般的 NoSQL)成为 RDBMS 的更好解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆