couchdb多个数据库 [英] couchdb multiple databases

查看:121
本文介绍了couchdb多个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用过mysql,但是对于我的下一个系列项目,CouchDB(NoSQL)似乎是必经之路,基本上是为了避免mysql中的EAV并包含其必须提供的所有出色功能。

I'm used to working with mysql but for my next series of projects CouchDB (NoSQL) seems to be the way to go, basically to avoid EAV in mysql and to embrace all the cool features it has to offer.

经过大量调查和阅读文档等后,我似乎不太了解一件事。

After lots of investigation and reading documentation etc, there is one thing I don't seem to understand quite well.

假设我在服务器上托管了三个Web应用程序,因此需要三个数据库。例如,一个是带有产品和发票表的网上商店,一个是带有文章和评论表的网络日志,另一个是带有游戏统计表的基于网络的游戏(显然是简化的)。

Lets assume I host three web applications on my server and thus need three databases accordingly. For instance one is a webshop with product and invoice tables, one is a weblog with article and comment tables and another one is a web based game with game stats tables (simplification obviously).

因此,我在一个安装的mysql上托管了多个站点,并且我在服务器上运行的每个应用程序都有自己的包含表,字段和内容的数据库。

So I host multiple sites on one installation of mysql, and each application I run on my server gets its own database with tables, fields and content.

现在,与CouchDb我想做完全一样的事情。问题似乎是在CouchDb中创建数据库与在mysql中创建表更相似。即我为自己的博客创建名为评论,文章等的数据库,并在其中为每个文章或每个评论创建一个文档。

Now, with CouchDb I want do the exact same thing. The problem seems to be that creating a database in CouchDb, is more similar to creating a table in mysql. I.e. I create databases called 'comments', 'articles' etc. for my weblog and inside I create a document per article or a document per comment.

所以我的问题是:如何在一个CouchDB安装中将我的数据与多个Web应用程序分开?

So my question is: how can I separate my data from multiple web applications on one CouchDB installation?

我认为我在这里做的根本上是错的,但希望你们中的一个能帮助我继续前进正确的轨道。

I think I am doing something fundamentally wrong here but hopefully one of you guys can help me get on the right track.

推荐答案

在CouchDB中,没有明确的需要将无关的数据分离到多个数据库中。如果您正确构建了文档和视图,则查询中只会显示相关数据。

In CouchDB, there's no explicit need to separate unrelated data into multiple databases. If you've constructed your documents and views correctly, only relevant data will appear in your queries.

如果您决定将数据分离到单独的数据库中,只需创建一个新数据库即可。

If you do decide to separate your data into separate databases, simply create a new database.

$ curl -X PUT http://localhost:5984/somedb
{"ok":true}

这篇关于couchdb多个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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