NoSQL最佳实践 [英] NoSQL best practices

查看:127
本文介绍了NoSQL最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NoSQL数据库,OODB或可能存在其他任何首字母缩写词的最佳实践是什么?

What are the best practices for NoSQL Databases, OODBs or whatever other acronyms may exist for them?

例如,我经常看到一个字段类型"用于确定客户端(应用程序)应如何解释数据库文档(以ouchDB/mongoDB术语).

For example, I've often seen a field "type" being used for deciding how the DB document (in couchDB/mongoDB terms) should be interpreted by the client, the application.

在适用的情况下,使用PHP作为参考语言.阅读:我也对如何在客户端最好地处理此类数据感兴趣,而不仅限于严格的数据库结构.实际上,这意味着我也在寻找SQL DB的模式("ORM")(活动记录,数据映射器等).

Where applicable, use PHP as a reference language. Read: I'm also interested in how such data can be best handled on the client side, not only strictly the DB structure. This means practically that I'm also looking for patterns like "ORM"s for SQL DBs (active record, data mapper, etc).

请毫不犹豫地声明这样的数据库和PHP 5.3的新功能如何最好地协同工作.

Don't hesitate making statements about how such a DB and the new features of PHP 5.3 could best work together.

推荐答案

我认为,目前,NoSQL数据存储的整体思想和文档数据库的概念是如此新颖,与推动关系存储的既定思想有所不同.目前很少(如果有的话)的最佳实践.

I think that currently, the whole idea of NoSQL data stores and the concept of document databases is so new and different from the established ideas which drive relational storage that there are currently very few (if any) best practices.

在这一点上,我们知道在CouchDB(或任何其他文档数据库)中存储数据的规则与关系型规则完全不同.例如,几乎不应该为3NF进行标准化和针对性这一事实.常见的例子之一就是一个简单的博客.

We know at this point that the rules for storing your data within say CouchDB (or any other document database) are rather different to those for a relational one. For example, it is pretty much a fact that normalisation and aiming for 3NF is not something one should strive for. One of the common examples would be that of a simple blog.

在关系商店中,您将分别具有一个用于帖子",评论"和作者"的表.每个作者将有很多帖子,每个帖子将有很多评论.这是一个运行良好的模型,可以在任何关系数据库上很好地映射.但是,在docDB中存储相同的数据很可能会大不相同.您可能会有一些类似Post文档的集合,每个集合都有自己的Author和Comment集合.当然,这可能不是唯一的方法,这是一种折衷(现在查询单个帖子的速度很快-您只需执行一项操作即可将所有内容退还给您,但是您无法维护作者与帖子之间的关系(因为所有内容都成为帖子文档的一部分).

In a relational store, you'd have a table each for "Posts", "Comments" and "Authors". Each Author would have many Posts, and each Post would have many Comments. This is a model which works well enough, and maps fine over any relational DB. However, storing the same data within a docDB would most likely be rather different. You'd probably have something like a collection of Post documents, each of which would have its own Author and collection of Comments embedded right in. Of course that's probably not the only way you could do it, and it is somewhat a compromise (now querying for a single post is fast - you only do one operation and get everything back), but you have no way of maintaining the relationship between authors and posts (since it all becomes part of the post document).

我也看到了使用"type"属性的示例(在CouchDB示例中).当然,这听起来是可行的方法.这是最好的吗?我没有头绪当然,在MongoDB中,您可能会在数据库中使用单独的集合,从而使type属性变得毫无意义.不过在CouchDB中...也许最好.其他选择?每种类型的文档都有单独的数据库?这似乎有点循环,所以我自己倾向于类型"解决方案.但这就是我.也许还有更好的东西.

I too have seen examples making use of a "type" attribute (in a CouchDB example). Sure, that sounds like a viable approach. Is it the best one? I haven't got a clue. Certainly in MongoDB you'd use seperate collections within a database, making the type attribute total nonsense. In CouchDB though... perhaps that is best. The other alternatives? Separate databases for each type of document? This seems a bit loopy, so I'd lean towards the "type" solution myself. But that's just me. Perhaps there's something better.

我意识到我已经在这里徘徊了很多时间,只说了很少,很可能你还不知道.不过,我的意思是-我认为我们应该尝试使用已有的工具和我们正在使用的数据,随着时间的推移,好的想法将会传播并成为最好的-实践.我只是认为您在游戏中提出的要求太早了.

I realise I've rambled on quite a bit here and said very little, most likely nothing you didn't already know. My point is this though - I think its up to us to experiment with the tools we've got and the data we're working with and over time the good ideas will be spread and become the best-practices. I just think you're asking a little too early in the game.

这篇关于NoSQL最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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