Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 33348 invoked from network); 8 Apr 2009 16:04:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Apr 2009 16:04:49 -0000 Received: (qmail 54213 invoked by uid 500); 8 Apr 2009 16:04:44 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 54152 invoked by uid 500); 8 Apr 2009 16:04:44 -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 54101 invoked by uid 99); 8 Apr 2009 16:04:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Apr 2009 16:04:44 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [209.85.219.166] (HELO mail-ew0-f166.google.com) (209.85.219.166) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Apr 2009 16:04:36 +0000 Received: by ewy10 with SMTP id 10so252689ewy.11 for ; Wed, 08 Apr 2009 09:04:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.210.43.10 with SMTP id q10mr1290839ebq.70.1239206655734; Wed, 08 Apr 2009 09:04:15 -0700 (PDT) Date: Wed, 8 Apr 2009 10:04:15 -0600 Message-ID: <35c58c40904080904o59df67a9n79655b2ee7a41f4d@mail.gmail.com> Subject: Query design questions From: Chris Kilmer To: CouchDB Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org I have some design questions. First about query design and then about document design. 1. Query design: We have a set of existing documents, Project, User, and Membership. Business constraints: A user is associated with many projects through membership. A user can also be marked as a project owner through the membership. A project can also retrieve a list of it's owners. Given the constraints, some sample documents are: User {'id' : 'xxx'} {'id' : 'yyy'} Project {'id' : 'aaa'} {'id' : 'ccc'} Membership {'user_id' : 'xxx', 'project' : 'aaa', 'is_owner' : true} {'user_id' : 'yyy', 'project' : 'aaa', 'is_owner' : false} {'user_id' : 'xxx', 'project' : 'bbb', 'is_owner' : true} {'user_id' : 'xxx', 'project' : 'ccc', 'is_owner' : true} What I'm wondering, is: 1. What is the easiest way to retrieve all the projects where a user is the(an) owner? (our current implementation uses two queries) 2. What is the easiest way to retrieve all the owners for a particular project? On another front, I realize the way the documents above are laid out is 'very relational'. I would love some ideas about on modeling the relationships (should I even be using that word?) in a more document centric manner. -- Chris Kilmer