You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by go canal <go...@yahoo.com> on 2009/09/23 04:51:00 UTC

how to work on multiple databases

Hello,
I am only one-day 'old' in the Couch world, CouchDB is really cool :-) 
I have a lot of questions though, sorry if these had been already answered...

Are there APIs available for working on multiple databases ? 

Here is the use case/data model:
 * a CouchDB database for one project
    all project related documents are stored in the DB.
 * a user can participate in multiple projects
 
let's say a user wants to display a list of his documents in all projects, how do we support this ? Do I have to issue one query command for each database then aggregate the result ?

thanks 
canal



      

Re: how to work on multiple databases

Posted by Michael Miller <mi...@cloudant.com>.
I may have missed the beginning of this thread, apologies if these  
were already discussed:

1) store the docs from different projects in the same db and use a  
view to sort them via project
2) same but pack the project name and user into the _id field and use  
the prebuilt _all_docs view to sort them via project/user
3) you can always combine db's using replication if you choose to  
aggregate at a later point in time.

Happy to follow up offline if you have more questions.

-Mike

On Oct 3, 2009, at 4:40 AM, Sven Helmberger wrote:

> go canal schrieb:
>> let's say a user wants to display a list of his documents in all  
>> projects, how do we support this ? Do I have to issue one query  
>> command for each database then aggregate the result ?
>
> You could create an external indexer that collects results from all  
> project databases.
>
> Regards,
> Sven


Re: how to work on multiple databases

Posted by Sven Helmberger <sv...@gmx.de>.
go canal schrieb:
>  
> let's say a user wants to display a list of his documents in all projects, how do we support this ? Do I have to issue one query command for each database then aggregate the result ?
> 

You could create an external indexer that collects results from all 
project databases.

Regards,
Sven

Re: how to work on multiple databases

Posted by go canal <go...@yahoo.com>.
thanks for a quick response. 

I agree that the use case is application specific; however, I tend to think that the data model is actually generic.

I do not know the design intent of a 'database' in CouchDB. For performance reason, and/or other something else. But I thought that since we have an API for getting all DBs, we might have something else for developers to manage a groups DBs.

 rgds,
canal




________________________________
From: Nadav Samet <th...@gmail.com>
To: user@couchdb.apache.org
Sent: Wednesday, September 23, 2009 11:03:58 AM
Subject: Re: how to work on multiple databases

The HTTP API works against one database at a time (at one http server). All
libraries I have seen will let you talk to multiple databases, but don't
have any functionality to send a single query to several databases and
aggregate the results. (This kind of functionality is too
application-specific to be in a general purpose library.)
On Tue, Sep 22, 2009 at 7:51 PM, go canal <go...@yahoo.com> wrote:

> Hello,
> I am only one-day 'old' in the Couch world, CouchDB is really cool :-)
> I have a lot of questions though, sorry if these had been already
> answered...
>
> Are there APIs available for working on multiple databases ?
>
> Here is the use case/data model:
>  * a CouchDB database for one project
>    all project related documents are stored in the DB.
>  * a user can participate in multiple projects
>
> let's say a user wants to display a list of his documents in all projects,
> how do we support this ? Do I have to issue one query command for each
> database then aggregate the result ?
>
> thanks
> canal
>
>
>
>




-- 
Sincerely yours,
Nadav



      

Re: how to work on multiple databases

Posted by go canal <go...@yahoo.com>.
that's really good news. hope it will be available for a projet I am working on now (to be delivered sometime around next June)
 rgds,
canal 




________________________________
From: Adam Kocoloski <ko...@apache.org>
To: user@couchdb.apache.org
Sent: Wednesday, September 23, 2009 7:42:01 PM
Subject: Re: how to work on multiple databases

On Sep 23, 2009, at 5:55 AM, go canal wrote:

> thanks.
> I quickly google, saw two lounge projects. guess this one is for the partitioning solution ? That's very good, I am about to ask this feature .....
> 
> Is there a plan to merge this into CouchDB core ?

Yes, CouchDB will definitely have partitioning, either via Lounge or an all-Erlang solution.  Best,

Adam



      

Re: how to work on multiple databases

Posted by Adam Kocoloski <ko...@apache.org>.
On Sep 23, 2009, at 5:55 AM, go canal wrote:

> thanks.
> I quickly google, saw two lounge projects. guess this one is for the  
> partitioning solution ? That's very good, I am about to ask this  
> feature .....
>
> Is there a plan to merge this into CouchDB core ?

Yes, CouchDB will definitely have partitioning, either via Lounge or  
an all-Erlang solution.  Best,

Adam

Re: how to work on multiple databases

Posted by go canal <go...@yahoo.com>.
thanks. 
I quickly google, saw two lounge projects. guess this one is for the partitioning solution ? That's very good, I am about to ask this feature .....

Is there a plan to merge this into CouchDB core ?

 rgds,
canal




________________________________
From: Chris Anderson <jc...@apache.org>
To: user@couchdb.apache.org
Sent: Wednesday, September 23, 2009 1:29:36 PM
Subject: Re: how to work on multiple databases

On Tue, Sep 22, 2009 at 8:03 PM, Nadav Samet <th...@gmail.com> wrote:
> The HTTP API works against one database at a time (at one http server). All
> libraries I have seen will let you talk to multiple databases, but don't
> have any functionality to send a single query to several databases and
> aggregate the results. (This kind of functionality is too
> application-specific to be in a general purpose library.)

The CouchDB-Lounge project has a query merging proxy which could be
adapted for this purpose.

> On Tue, Sep 22, 2009 at 7:51 PM, go canal <go...@yahoo.com> wrote:
>
>> Hello,
>> I am only one-day 'old' in the Couch world, CouchDB is really cool :-)
>> I have a lot of questions though, sorry if these had been already
>> answered...
>>
>> Are there APIs available for working on multiple databases ?
>>
>> Here is the use case/data model:
>>  * a CouchDB database for one project
>>    all project related documents are stored in the DB.
>>  * a user can participate in multiple projects
>>
>> let's say a user wants to display a list of his documents in all projects,
>> how do we support this ? Do I have to issue one query command for each
>> database then aggregate the result ?
>>
>> thanks
>> canal
>>
>>
>>
>>
>
>
>
>
> --
> Sincerely yours,
> Nadav
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io



      

Re: how to work on multiple databases

Posted by Chris Anderson <jc...@apache.org>.
On Tue, Sep 22, 2009 at 8:03 PM, Nadav Samet <th...@gmail.com> wrote:
> The HTTP API works against one database at a time (at one http server). All
> libraries I have seen will let you talk to multiple databases, but don't
> have any functionality to send a single query to several databases and
> aggregate the results. (This kind of functionality is too
> application-specific to be in a general purpose library.)

The CouchDB-Lounge project has a query merging proxy which could be
adapted for this purpose.

> On Tue, Sep 22, 2009 at 7:51 PM, go canal <go...@yahoo.com> wrote:
>
>> Hello,
>> I am only one-day 'old' in the Couch world, CouchDB is really cool :-)
>> I have a lot of questions though, sorry if these had been already
>> answered...
>>
>> Are there APIs available for working on multiple databases ?
>>
>> Here is the use case/data model:
>>  * a CouchDB database for one project
>>    all project related documents are stored in the DB.
>>  * a user can participate in multiple projects
>>
>> let's say a user wants to display a list of his documents in all projects,
>> how do we support this ? Do I have to issue one query command for each
>> database then aggregate the result ?
>>
>> thanks
>> canal
>>
>>
>>
>>
>
>
>
>
> --
> Sincerely yours,
> Nadav
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: how to work on multiple databases

Posted by Nadav Samet <th...@gmail.com>.
The HTTP API works against one database at a time (at one http server). All
libraries I have seen will let you talk to multiple databases, but don't
have any functionality to send a single query to several databases and
aggregate the results. (This kind of functionality is too
application-specific to be in a general purpose library.)
On Tue, Sep 22, 2009 at 7:51 PM, go canal <go...@yahoo.com> wrote:

> Hello,
> I am only one-day 'old' in the Couch world, CouchDB is really cool :-)
> I have a lot of questions though, sorry if these had been already
> answered...
>
> Are there APIs available for working on multiple databases ?
>
> Here is the use case/data model:
>  * a CouchDB database for one project
>    all project related documents are stored in the DB.
>  * a user can participate in multiple projects
>
> let's say a user wants to display a list of his documents in all projects,
> how do we support this ? Do I have to issue one query command for each
> database then aggregate the result ?
>
> thanks
> canal
>
>
>
>




-- 
Sincerely yours,
Nadav

Re: how to work on multiple databases

Posted by go canal <go...@yahoo.com>.
Yes. For me it's a feature, rather than a bug, that couchdb databases are
completely isolated from each other. Maybe you should consider lumping
everything into one database.


>> I can understand that couchdb DBs are completely isolated, I also agree that logically it is ok. But since there is no other layer we can use within a DB for modeling, I think operations on multiple databases are desired.

It does seem that putting something I need into one DB is the only way. Maybe it is acceptable since couchdb works incrementally, so performance won't be a problem even there is a large number of records because of combining multiple DBs into one ....
 rgds,
canal



      

Re: how to work on multiple databases

Posted by Brian Candler <B....@pobox.com>.
On Tue, Sep 22, 2009 at 07:51:00PM -0700, go canal wrote:
> Are there APIs available for working on multiple databases ? 

I contributed a change to CouchRest which lets you do

    Foo.on(database).whatever

which directs your request to a database dynamically.

I haven't tested this in a while - I found CouchRest too complex internally
so I ended up knocking together my own API (couchtiny). I published it on
github.com/candlerb, although it's subject to change at my own whim :-)

> let's say a user wants to display a list of his documents in all projects,
> how do we support this ? Do I have to issue one query command for each
> database then aggregate the result ?

Yes. For me it's a feature, rather than a bug, that couchdb databases are
completely isolated from each other. Maybe you should consider lumping
everything into one database.

Regards,

Brian.