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 2EE2B4129 for ; Fri, 10 Jun 2011 13:17:26 +0000 (UTC) Received: (qmail 27728 invoked by uid 500); 10 Jun 2011 13:17:22 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 27672 invoked by uid 500); 10 Jun 2011 13:17:22 -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 27633 invoked by uid 99); 10 Jun 2011 13:17:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jun 2011 13:17:22 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sean.copenhaver@gmail.com designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vw0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jun 2011 13:17:16 +0000 Received: by vws16 with SMTP id 16so3155505vws.11 for ; Fri, 10 Jun 2011 06:16:55 -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; bh=BEO34qMxV6yGOY17LIKonoMjd76mqJKdSweYAqtNzSk=; b=hzQcj25l8oNvYlAaAm9Y7psB9u56UpyOp2CpvFgpF8DQpXG4U/xY+FKzMWrN5VSAO1 jlWLru9XSQ+Ef8FY/BM9Kfs0Or1Ym1S3EdpsmhDjdD/XuxXu2XGI7uBYYt/hH2kKG//Q hHSTXP1R2NWOk95mzbOLudsHsw09hJHCh9N5I= 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; b=TazSA/g6W0VncfFq090d1mYZqm6mjt3Dj4TrJWkx9u2domht01qJE9uQQnwhvrtZSI DbMIkdi9WVcDwe+WEDVLbzB8qKFvNz1uZgn+Iv+ngS2qjzXanrSFhSESHrYf0FS4Z34p iCVTiU3vwS8cD10tm29WvBFM/BiHLKIWOFG7Q= MIME-Version: 1.0 Received: by 10.52.175.197 with SMTP id cc5mr2933635vdc.287.1307711815468; Fri, 10 Jun 2011 06:16:55 -0700 (PDT) Received: by 10.52.185.167 with HTTP; Fri, 10 Jun 2011 06:16:55 -0700 (PDT) In-Reply-To: References: Date: Fri, 10 Jun 2011 09:16:55 -0400 Message-ID: Subject: Re: Help with data modelling From: Sean Copenhaver To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=bcaec51a7d423ac5f804a55b6207 --bcaec51a7d423ac5f804a55b6207 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Ah I think I see what you mean: "*all-or-nothing* - To use this mode, include "all_or_nothing":true as part of the request. In the case of a power failure, when the database restarts either all the changes will have been saved or none of them. However, it does not do conflict checking, so the documents will be committed even if this creates conflicts" So even though you "transactional" committed multiple documents, when you retrieved them you won't always get what you committed. On Fri, Jun 10, 2011 at 8:47 AM, Robert Newson wro= te: > 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. > What > > were your concerns that you would want to put all manufacturers in a > single > > document or all log entries for example? That is instead of in a view > query > > result? > > > > I don't think there would be an issue with having everything as a > separate > > document. There are ways to pull back related documents in one query th= at > > would resolve concerns of having to do many hits. As an example, you > could > > create a view to be able to pull back the device, user, and profile in > one > > 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 > you > > 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 > from > >> SQL to NoSQL. I have designed different approaches to model the CouchD= B > >> 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 > still > >> have some doubts. Basically the data model of my application domain ha= s > the > >> following scheme: > >> > >> *Data model overview* > >> > >> - Mobile manufacturers (in the order of 60). Each manufacturer has > >> different models: > >> - Mobile models (in the order of 2000 per manufactorer) > >> - Errors. Each manufacturer has a set of types of errors (in the ord= er > of > >> 1000 per manufacturer) > >> - User > >> - Mobile device > >> - Profile. Identified by a User and a MobileDevice > >> - DebugLog. Each debug log takes just 10 words and one DebugLog per > >> second is sent to the server. > >> - ErrorLog. Each error log takes just 10 words and they are generate= d > >> once in a while. > >> - So, my main doubts are listed below: > >> > >> > >> *Doubt 1 (manufacturers and models)* > >> > >> - Option 1 > >> - One document for all the manufacturers: "Manufacturers". It jus= t > >> includes a list of manufacturers, each of them has an identifier. > >> - One document per model: "ModelX". Each model includes a referen= ce > to > >> its manufacturer. > >> - Option 2 > >> - One document for all the manufacturers: "Manufacturers". It > includes > >> a list of manufacturers. Each manufacturer points to a list of > models. > >> - One document per manufacturer: "ListOfModels". It includes all > the > >> models for a given manufacturer. > >> > >> *Doubt 2 (logs)* > >> > >> - Option 1 > >> - One document per DebugLog: "DebugLogX". > >> - Option 2 > >> - One document per application life cycle: > >> "DebugLogsDuringApplicationLifeCycleX". It includes all the debug > logs > >> created by the application during its life cycle. An application > >> life cycle > >> might takes from just a few seconds to some hours. > >> > >> *Doubt 3 (user, mobile and profile)* > >> > >> - Option 1 > >> - One document per profile: "ProfileX". It includes information > about > >> the mobile device and the user. > >> - Option 2 > >> - One document per user: "UserX" > >> - One document per device: "DeviceX" > >> - One document for all the profiles: "Profiles". It contains a li= st > of > >> profiles, each one pointing to its associated user and device. > >> > >> > >> *Doubt 4 (manufacturer errors)* > >> > >> - Option 1 > >> - One document for all the errors. Each error is associated to it= s > >> manufacturer. > >> - Option 2 > >> - 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_10= ?ie=3DUTF8&qid=3D1307691243&sr=3D8-10 > >> [2] > >> > >> > http://www.amazon.com/CouchDB-Definitive-Guide-Animal-ebook/dp/B0043D2E9U= /ref=3Dsr_1_3?ie=3DUTF8&qid=3D1307691243&sr=3D8-3 > >> > > > > > > > > -- > > =93The limits of language are the limits of one's world. =93 -Ludwig vo= n > > Wittgenstein > > > --=20 =93The limits of language are the limits of one's world. =93 -Ludwig von Wittgenstein --bcaec51a7d423ac5f804a55b6207--