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 C55C546F0 for ; Fri, 10 Jun 2011 12:47:47 +0000 (UTC) Received: (qmail 74209 invoked by uid 500); 10 Jun 2011 12:47:46 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 74177 invoked by uid 500); 10 Jun 2011 12:47:46 -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 74169 invoked by uid 99); 10 Jun 2011 12:47:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jun 2011 12:47:46 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of robert.newson@gmail.com designates 74.125.82.54 as permitted sender) Received: from [74.125.82.54] (HELO mail-ww0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jun 2011 12:47:38 +0000 Received: by wwd20 with SMTP id 20so2405847wwd.23 for ; Fri, 10 Jun 2011 05:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=t75+uWuchR0EkAz4v0NNIov2OzSASmZqU3T2H+vSuiA=; b=eyXFXbA5U6i1vCg7CFb09hZYfrRmOqFrwVXyPmAinel5kHeF4OtnipdUCDjrez2PHW qs3qikFrxyrJNN69WRTeUZN4SgIGrpUCtdzyC0bLbSqUJxdR7Ckf1f7bcF1zmNqXFrpX 4TtllHLoAQqy6m8pRXmbS8miGiVbyq76yVQ+g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=tLIPbURw6WDRtuHanBgO9CnB/ubKWDfaNGUplmsUyiwkasyraF2Avkt0rJq/0e43EP G+WfTgaXP1VLteo9Js/V4E/DipQSI/HfbbNvaQyBgotOgvJPRV6NYL1Yj7XNI+34/zLP mtIkvtQTNmfDLTCQv40xAP46iEZY9Rq94Yipo= MIME-Version: 1.0 Received: by 10.216.233.207 with SMTP id p57mr1970159weq.72.1307710037786; Fri, 10 Jun 2011 05:47:17 -0700 (PDT) Received: by 10.216.22.69 with HTTP; Fri, 10 Jun 2011 05:47:17 -0700 (PDT) In-Reply-To: References: Date: Fri, 10 Jun 2011 13:47:17 +0100 Message-ID: Subject: Re: Help with data modelling From: Robert Newson To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org The bulk documents API is not transactional in any useful sense. On 10 June 2011 13:42, Sean Copenhaver wrote: > It sounds like you are trying to combine things into a single document. W= hat > were your concerns that you would want to put all manufacturers in a sing= le > document or all log entries for example? That is instead of in a view que= ry > result? > > I don't think there would be an issue with having everything as a separat= e > document. There are ways to pull back related documents in one query that > would resolve concerns of having to do many hits. As an example, you coul= d > create a view to be able to pull back the device, user, and profile in on= e > query. > > The wiki has some information on managing relationships: > http://wiki.apache.org/couchdb/EntityRelationship > > On the flip side there are ways to perform CRUD operations on multiple > documents at once, including transactional (although with multiple dbs yo= u > can run into inconsistencies as the transaction won't hold up across > replication): > http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API > > > 2011/6/10 Javier Rodr=EDguez Escolar > >> Hello, I'm a CouchDB newbie trying to migrate an existing application fr= om >> SQL to NoSQL. I have designed different approaches to model the CouchDB >> documents and I have been leafing through a couple of books [1],[2] in >> order >> to figure out the possible problems each approach might cause, but I sti= ll >> have some doubts. Basically the data model of my application domain has = the >> following scheme: >> >> *Data model overview* >> >> =A0 - Mobile manufacturers (in the order of 60). Each manufacturer has >> =A0 different models: >> =A0 - Mobile models (in the order of 2000 per manufactorer) >> =A0 - Errors. Each manufacturer has a set of types of errors (in the ord= er of >> =A0 1000 per manufacturer) >> =A0 - User >> =A0 - Mobile device >> =A0 - Profile. Identified by a User and a MobileDevice >> =A0 - DebugLog. Each debug log takes just 10 words and one DebugLog per >> =A0 second is sent to the server. >> =A0 - ErrorLog. Each error log takes just 10 words and they are generate= d >> =A0 once in a while. >> =A0 - So, my main doubts are listed below: >> >> >> *Doubt 1 (manufacturers and models)* >> >> =A0 - Option 1 >> =A0 =A0 =A0- One document for all the manufacturers: "Manufacturers". It= just >> =A0 =A0 =A0includes a list of manufacturers, each of them has an identif= ier. >> =A0 =A0 =A0- One document per model: "ModelX". Each model includes a ref= erence to >> =A0 =A0 =A0its manufacturer. >> =A0 - Option 2 >> =A0 =A0 =A0- One document for all the manufacturers: "Manufacturers". It= includes >> =A0 =A0 =A0a list of manufacturers. Each manufacturer points to a list o= f models. >> =A0 =A0 =A0- One document per manufacturer: "ListOfModels". It includes = all the >> =A0 =A0 =A0models for a given manufacturer. >> >> *Doubt 2 (logs)* >> >> =A0 - Option 1 >> =A0 =A0 =A0- One document per DebugLog: "DebugLogX". >> =A0 - Option 2 >> =A0 =A0 =A0- One document per application life cycle: >> =A0 =A0 =A0"DebugLogsDuringApplicationLifeCycleX". It includes all the d= ebug logs >> =A0 =A0 =A0created by the application during its life cycle. An applicat= ion >> life cycle >> =A0 =A0 =A0might takes from just a few seconds to some hours. >> >> *Doubt 3 (user, mobile and profile)* >> >> =A0 - Option 1 >> =A0 =A0 =A0- One document per profile: "ProfileX". It includes informati= on about >> =A0 =A0 =A0the mobile device and the user. >> =A0 - Option 2 >> =A0 =A0 =A0- One document per user: "UserX" >> =A0 =A0 =A0- One document per device: "DeviceX" >> =A0 =A0 =A0- One document for all the profiles: "Profiles". It contains = a list of >> =A0 =A0 =A0profiles, each one pointing to its associated user and device= . >> >> >> *Doubt 4 (manufacturer errors)* >> >> =A0 - Option 1 >> =A0 =A0 =A0- One document for all the errors. Each error is associated t= o its >> =A0 =A0 =A0manufacturer. >> =A0 - Option 2 >> =A0 =A0 =A0- One document per manufacturer: "ManufacturerXErrors". >> >> >> I would appreciate any piece of advice. >> >> Thanks in advance and congrats for your project, >> >> >> [1] >> >> http://www.amazon.com/Beginning-CouchDB-ebook/dp/B003U890N2/ref=3Dsr_1_1= 0?ie=3DUTF8&qid=3D1307691243&sr=3D8-10 >> [2] >> >> http://www.amazon.com/CouchDB-Definitive-Guide-Animal-ebook/dp/B0043D2E9= U/ref=3Dsr_1_3?ie=3DUTF8&qid=3D1307691243&sr=3D8-3 >> > > > > -- > =93The limits of language are the limits of one's world. =93 -Ludwig von > Wittgenstein >