Reputation: 8961
JOINING data in a 'sql-esque' way is possible within MapReduce as mentioned in many places - such as these Standford course notes, and this MSc thesis, and a plagiarized copy of that thesis published by http://ijniet.org :p.
I have 3 Entities:
A
B
C
A
and B
can be joined on column ab
, and BC
can be joined on column bc
. I think that I can achieve this via cascading MapReduce tasks. But that I CAN'T do that in CouchDB in any way, whether that is with Map functions, reduce functions, list functions (that consume a MapReduce view), or a combination of these...
In CouchDB you could output documents of different entities with the same join key. But as far as I can tell there is no possible map function that allows for grouping multiple entities by either the same key, or a key range?
This is specifically for JOINS where Foreign key columns are different for each join.
Upvotes: 1
Views: 41
Reputation: 3690
You can't do cascade joins in CouchDB.
The only joins that you can do are one-to-many joins.
It consists of a view that emits the linked documents as a value:
function(doc){
emit([doc._id,0]);
emit([doc.ab,1],{_id:doc.ab});
}
Then you query with ?include_docs=true
You would get something like this:
{rows:[
{key:["my_main_doc_id",0],doc:{my main document...}},
{key:["my_main_doc_id",1],doc:{child doc...}}
]}
See this documentation
Upvotes: 1