incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <d...@muse.net.nz>
Subject Re: SQL-like-JOINs?
Date Tue, 14 Sep 2010 03:44:18 GMT
Also a good post on
http://blog.couchone.com/post/446015664/whats-new-in-apache-couchdb-0-11-part-two-views
about this functionality.
dch

On 14 September 2010 04:34, Kenneth Tyler <ken@8thfold.com> wrote:
> Wolfgang,
> If you look here:
> http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views
> at the topic "linked documents"
> you will see that: "This means that if one document contains the ids of
> other documents, it can cause those documents to be fetched in the view too,
> adjacent to the same key if required."
>
> this means that you can include your sub-document names as a list in your
> main document:
> {
>   "Object List": [
>       "Object A",
>       "Object B"
>   ]
> }
>
> and in your view you can use the names in the object list to pull in the
> document about the object with the additional information. This means that
> you will have to create the reference document with the string "Object A",
> for example,  as its key, rather than a randomly generated key. Then if you
> have to update the additional information for object a, every time the view
> pulls in the "Object A" document it will get the new information.
>
>
>
> so this way your objects and tools are lists in the main document.. and the
> lists include a  name that can be used to pull in the "more information"
> document for each object or tool.
>
> it might help to add a "type" field for the lookup documents for objects and
> tools: {"type":"object"}
> so then you can make a view that will list all the "object" lookup
> documents.
>
> this is a good example of how a problem that needs to be solved with a join
> in sql does not require a join in couchdb...because in couchdb lists can be
> kept in the document itself, rather than the document storing links to other
> records that make up the list.
>
>
> ken tyler
>
> On Mon, Sep 13, 2010 at 8:58 AM, Wolfgang Egger <beuys@wolfgang-egger.de>wrote:
>
>> Kenneth Tyler <ken@...> writes:
>>
>> >
>> > Wolfgang,
>> > Just like in SQL, the first question is what is common to the two (or
>> more)
>> > documents that you want to combine ?
>> > Do they have the same type ? Are they in a certain date range ? Do they
>> > share some other field of information ?
>>
>>
>> There is one MainDocument, that references to some "Sub"-Documents.
>>
>> Say you have a manual, how to build one thing from three smaller parts.
>>
>> Somethng like:
>> You need:
>> Object A
>> Object B
>> Object C
>> You use:
>> Tool A
>> Tool B
>> Tool C
>>
>> HowTo:
>> Put Object A together with Object B by using Tool A upon Object C
>> ......
>>
>> This is the MainDocument.
>> Ther are Documents, that describe Object A .. Object C and the Tools, this
>> are
>> the "Sub" Documents.
>>
>> I want to show The MainDocument and e.g. some "Teasers" with a
>> short-description
>> of the Tools and Objects together with som links, to the whole
>> Description-Documents.
>>
>> If the Descriptions will change or updated, this changes shoud be reflected
>> ,
>> without the need to change them "mqnually" within the MainDocument.
>>
>> Wolfgang
>>
>>
>

Mime
View raw message