Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 84251 invoked from network); 5 Nov 2009 19:12:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Nov 2009 19:12:33 -0000 Received: (qmail 78702 invoked by uid 500); 5 Nov 2009 19:12:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 78649 invoked by uid 500); 5 Nov 2009 19:12:32 -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 78639 invoked by uid 99); 5 Nov 2009 19:12:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Nov 2009 19:12:32 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of awolff@gmail.com designates 209.85.216.201 as permitted sender) Received: from [209.85.216.201] (HELO mail-px0-f201.google.com) (209.85.216.201) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Nov 2009 19:12:29 +0000 Received: by pxi39 with SMTP id 39so334755pxi.30 for ; Thu, 05 Nov 2009 11:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=3/gxEymiYx+bk+CyeTMI40fqdDWao2ivjCSd6ceriE8=; b=d3NienKQndAThyL0WlFGSqpATYa8LfINApLCSdI/NTIRvPceG3JKw5VzDKD0gEPvq/ U79FFTFRULsnOFOZwJeO6Rj7cefva66HYv+7se3ttjfUlndb7rzPZkAGuUXTbPJ4CUWH ZQnGhdJNm2rfmfhJRd175c0emkkoQAl6HyHsc= 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=P/FuzuDt1DQVEFPZHO08hKc1WsgNVvyZy1zSEFvck1zJbf/M7nADEo+y0SsbE34TIa UeQC2W1FwzNh/IMrDOgG+A8cqxW9en/Uw+WApZupJr9FK78JvG613kw+3msHmUywfwGF NH5XK2yUsEYOsIsE2fFpevkrEQGmbTaMC9R3Q= MIME-Version: 1.0 Received: by 10.140.177.18 with SMTP id z18mr168673rve.227.1257448328993; Thu, 05 Nov 2009 11:12:08 -0800 (PST) In-Reply-To: References: <5324CCF9-9806-482B-B30C-B07F1340F077@apache.org> Date: Thu, 5 Nov 2009 11:12:08 -0800 Message-ID: Subject: Re: How do you handle multiple document groups? From: Adam Wolff To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000e0cd21222f91c150477a48094 --000e0cd21222f91c150477a48094 Content-Type: text/plain; charset=ISO-8859-1 Can I ask what the advantage of this is? Is this for replication? I like having typed databases; it seems like that will be an easy way to solve scaling problems. A On Thu, Nov 5, 2009 at 3:03 AM, Jan Lehnardt wrote: > > On 5 Nov 2009, at 11:47, Robert Campbell wrote: > > Okay, I _do_ like that CouchDB lets me use "/" in a database name, so >> I can hopefully do "http://xxx/myapp_com/users" which feels better >> thanks to the / delimiter. >> >> For something like "myapp.com" domain and "users" database. I'll just >> have to replace all periods with underscores or something. >> > > I wouldn't create databases per type. > > say user a has the domains foo.com and bar.com > > for that user the databases /a/foo_com/ and /a/bar_com > are created. In these databases, all documents for the > respective domain live. If you need additional info for > the user that owns the domain that is not specific to > the domain, I'd go with putting all user-specific info > in each of the user's databases. This is duplication, > but it doesn't really hurt, except maybe for users > with hundreds and thousands of domains. In which > case he/she probably pays you enough money to > solve it :) > > Cheers > Jan > -- > > > > >> >> On Thu, Nov 5, 2009 at 11:19 AM, Jan Lehnardt wrote: >> >>> >>> On 5 Nov 2009, at 11:02, Robert Campbell wrote: >>> >>> First, let me say that I posted this question to StackOverflow here: >>>> http://stackoverflow.com/questions/1674662/nested-databases-in-couchdb >>>> >>>> Here is what I mean by multiple document groups: >>>> Assume you are building a blog engine which services hundreds of >>>> domains. Within each domain, you would have similar groups of >>>> documents: users, posts, comments, etc. How would you structure this >>>> in CouchDB? >>>> >>>> One way would be to create a User database which contains users from >>>> all domains. The user documents would have a "domain" field which >>>> denotes which domain this user is valid on. Likewise, you would have a >>>> single Post database, with each post document having a domain field >>>> and so on. I don't like this solution because 1) you will have lots of >>>> data duplication, where every single document has to denote the domain >>>> it's connected to. 2) It seems like it could be a security problem. >>>> One vulnerability in your view functions could accidentally return one >>>> domain's user set to another, etc. If we change the blog engine into >>>> an enterprise document management/workflow engine, you could have >>>> serious problems exposing one document to a competitor. >>>> >>>> Another way you could do it is by bringing the domain group up into >>>> the database level. This means you'd have "MyApp.com-Users", >>>> "MyApp.com-Posts", "MyApp.com-Comments", "AnotherApp.net-Users", etc. >>>> This helps reduce the data duplication and maybe the security issue a >>>> bit, because now your documents don't need to specify a "domain" field >>>> everywhere. Your app would follow the simple naming convention to >>>> select the proper database. The disadvantage of this is that it feels >>>> like a hack. What I really want is a MyApp database which contains >>>> User, Post, and Comment sub-databases (for example) which then contain >>>> the documents for that top-level group (domain) and lower-level group >>>> (posts). >>>> >>>> How do you guys address this problem? >>>> >>> >>> Give each user/domain combo a separate database. Lot's of databases are >>> no >>> problem. >>> >>> Cheers >>> Jan >>> -- >>> >>> >>> >> > --000e0cd21222f91c150477a48094--