Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 196C090AB for ; Mon, 7 Nov 2011 00:40:40 +0000 (UTC) Received: (qmail 66546 invoked by uid 500); 7 Nov 2011 00:40:38 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 66515 invoked by uid 500); 7 Nov 2011 00:40:38 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 66506 invoked by uid 99); 7 Nov 2011 00:40:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 00:40:38 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=DC_PNG_UNO_LARGO,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of alex.barbalex@gmail.com designates 209.85.220.180 as permitted sender) Received: from [209.85.220.180] (HELO mail-vx0-f180.google.com) (209.85.220.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2011 00:40:30 +0000 Received: by vcbfo1 with SMTP id fo1so288413vcb.11 for ; Sun, 06 Nov 2011 16:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=X1Bkl/m9jgXmxk7t/TKbekYowNgeksXHy2nbvQTYe2M=; b=Wb8MQkwemVoz7R4/n3Es44Cp3PUuqN42ogBplUmbNiNSITsJWunhZe1rFKYeoTWXrs 1Vs2XeDflpAJyzGvyWJWv8r5o40rlIHu/asOWEFaUxoW6NBlf+jHcYHmqYVCFOTkvaFl 8e5Skwat2kpokMhCbNr2q8M9xVuXLdw6R/Dq0= MIME-Version: 1.0 Received: by 10.52.116.237 with SMTP id jz13mr19372173vdb.90.1320626409395; Sun, 06 Nov 2011 16:40:09 -0800 (PST) Sender: alex.barbalex@gmail.com Received: by 10.52.114.196 with HTTP; Sun, 6 Nov 2011 16:40:09 -0800 (PST) In-Reply-To: <6649CCED-C1CF-40F9-9751-BC922D02031C@utt.fr> References: <6649CCED-C1CF-40F9-9751-BC922D02031C@utt.fr> Date: Mon, 7 Nov 2011 01:40:09 +0100 X-Google-Sender-Auth: -2QRWqZsXHDYi8nt8KyzPQOaRSQ Message-ID: Subject: Re: How to get hierarchicaly linked data into one line? From: Alexander Gabriel To: user@couchdb.apache.org Content-Type: multipart/related; boundary=bcaec548643203577104b11a4cea X-Virus-Checked: Checked by ClamAV on apache.org --bcaec548643203577104b11a4cea Content-Type: multipart/alternative; boundary=bcaec548643203576e04b11a4ce9 --bcaec548643203576e04b11a4ce9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Aurelien Thanks for helping. I have tried to collate the lines of hierarchically linked documents now. This is what my view looks like: *function(doc) {* * var User =3D doc.User;* * if(doc.Typ =3D=3D 'Projekt'){* * emit ([User, doc._id, {}, {}, {}, {}], doc);* * } else if (doc.Typ =3D=3D 'Raum') {* * emit ([User, doc.ProjektId, doc._id, {}, {}, {}], doc);* * } else if (doc.Typ =3D=3D 'Ort') {* * emit ([User, doc.ProjektId, doc.RaumId, doc._id, {}, {}], doc);* * } else if (doc.Typ =3D=3D 'Zeit') {* * emit ([User, doc.ProjektId, doc.RaumId, doc.OrtId, doc._id, {}], doc);= * * } else if (doc.Typ =3D=3D 'Art') {* * emit ([User, doc.ProjektId, doc.RaumId, doc.OrtId, doc.ZeitId, doc._id], doc);* * }* *}* The hierarchies are: Projekt, Raum, Ort, Zeit and Art. In the Output of the list linked lines follow each other now. Thats as good as I could expect this sort of List to become. It would be great to build a tree view: (note: I deleted most fields) [image: image.png] The Result is not what the Users will expect though: Although every line contains the id's of all hierarchies, only one contains the attributes of it. You will have some work to see visually what are the attributes of the Projekt (higher order hierarchy) of a Art (lowest order hierarchy). You can't filter the table by an attribute of a Projekt (higher order hierarchy) and get all its lines (sightings of species). That is why I am searching for a method to get the data of all hierarchies on one single line per sighting (lowest order or hierarchy). Thanks a lot though for helping me get this far. Alex 2011/11/6 Aur=C3=A9lien B=C3=A9nel > Hi Alexander, > > > But I can't figure out how to create a view/list with all the data of a > sighting on one line. This would be easy with a relational database. I mu= st > be missing something. I've seen this ( > http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Linked_docum= ents) > but it puts related data on neighbouring lines. > > You don't have to put them on the same line. > > When you query a view, you don't get just a line, but all the lines that > corresponds to the key or to the range of keys you gave. > This means that you can "collate" lines coming from different documents : > http://wiki.apache.org/couchdb/View_collation > > > Regards, > > Aur=C3=A9lien --bcaec548643203576e04b11a4ce9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Aurelien

Thanks for helping.

I have tried to collate the lines of hierarchically linked documents now. = This is what my view looks like:
function(doc) {
=C2=A0 =C2=A0 var User = =3D doc.User;
if(= doc.Typ =3D=3D 'Projekt'){
emit ([User, doc._id, {}, {}, {}= , {}], doc);
} e= lse if (doc.Typ =3D=3D 'Raum') {
=C2=A0 =C2=A0emit ([User, doc.Pr= ojektId, doc._id, {}, {}, {}], doc);
=C2=A0 =C2=A0 } else if (doc.Typ =3D=3D '= Ort') {
=C2=A0 =C2=A0emit ([User, doc.Pr= ojektId, doc.RaumId, doc._id, {}, {}], doc);
=C2=A0 =C2=A0 } else if (doc.Typ =3D= =3D 'Zeit') {
=C2=A0 =C2=A0emit ([User, doc.Pr= ojektId, doc.RaumId, doc.OrtId, doc._id, {}], doc);
=C2=A0 =C2=A0 } else if (doc.T= yp =3D=3D 'Art') {
=C2=A0 =C2=A0emit ([User, doc.Pr= ojektId, doc.RaumId, doc.OrtId, doc.ZeitId, doc._id], doc);
=C2=A0 =C2=A0 }=
}
The hierarchies are: Projekt, Raum, Ort, Zeit and Art.

=
In the Output of the list linked lines follow each other now. Th= ats as good as I could expect this sort of List to become. It would be grea= t to build a tree view: (note: I deleted most fields)
3D"image.png"

The Result is not what the Users will ex= pect though:=C2=A0Although every line contains the id's of all hierarch= ies, only one contains the attributes of it. You will have some work to see= visually what are the attributes of the Projekt (higher order hierarchy) o= f a Art (lowest order hierarchy). You can't filter the table by an attr= ibute of a Projekt (higher order hierarchy) and get all its lines (sighting= s of species).

That is why I am searching for a method to get the data= of all hierarchies on one single line per sighting (lowest order or hierar= chy).

Thanks a lot though for helping me get this = far.

Alex






2011/11/6 Aur=C3=A9lien B=C3=A9nel <aurelien.benel@ut= t.fr>
Hi Alexander,

> But I can't figure out how to create a view/list with all the data= of a sighting on one line. This would be easy with a relational database. = I must be missing something. I've seen this (http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Linked_= documents) but it puts related data on neighbouring lines.

You don't have to put them on the same line.

When you query a view, you don't get just a line, but all the lines tha= t corresponds to the key or to the range of keys you gave.
This means that you can "collate" lines coming from different doc= uments :
http://wiki.apache.org/couchdb/View_collation


Regards,

Aur=C3=A9lien

--bcaec548643203576e04b11a4ce9-- --bcaec548643203577104b11a4cea--