Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 64171 invoked from network); 11 Feb 2010 13:35:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Feb 2010 13:35:48 -0000 Received: (qmail 90607 invoked by uid 500); 11 Feb 2010 13:35:47 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 90539 invoked by uid 500); 11 Feb 2010 13:35: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 90528 invoked by uid 99); 11 Feb 2010 13:35:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Feb 2010 13:35:46 +0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [195.85.130.100] (HELO smtp.atwork.nl) (195.85.130.100) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Feb 2010 13:35:35 +0000 Received: from localhost (localhost [127.0.0.1]) by smtp.atwork.nl (Postfix) with ESMTP id 30FE313F89E for ; Thu, 11 Feb 2010 14:35:14 +0100 (CET) Received: from waldo.buyways.nl (atwork-154.r-212.178.116.atwork.nl [212.178.116.154]) by smtp.atwork.nl (Postfix) with ESMTP id B07A713FA9F for ; Thu, 11 Feb 2010 14:18:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by waldo.buyways.nl (Postfix) with ESMTP id 38D3C3A1690 for ; Thu, 11 Feb 2010 14:18:47 +0100 (CET) Received: from waldo.buyways.nl ([127.0.0.1]) by localhost (waldo.buyways.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nKCMNl8KpBCG for ; Thu, 11 Feb 2010 14:18:47 +0100 (CET) Received: from zealand.localnet (beauregard.buyways.nl [192.168.217.1]) by waldo.buyways.nl (Postfix) with ESMTP id 1B7F33A168F for ; Thu, 11 Feb 2010 14:18:47 +0100 (CET) From: Markus Jelsma Reply-To: markus@buyways.nl Organization: Buyways To: user@couchdb.apache.org Subject: Re: Tips for many to many Date: Thu, 11 Feb 2010 14:18:46 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.31-19-generic; KDE/4.3.2; i686; ; ) References: <21a5a18d1002102026j58849e69q3f85df73fc72d0e8@mail.gmail.com> In-Reply-To: <21a5a18d1002102026j58849e69q3f85df73fc72d0e8@mail.gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201002111418.46867.markus@buyways.nl> X-Virus-Scanned: by @Work X-Virus-Checked: Checked by ClamAV on apache.org Hi, You can explicitely list the relations for each entity in its own document, negating the need for a link-table. doc{ _id : channel_x1 type : channel .. .. lineups : [lineup_y1, lineup_y2] } Now you have a channel document pointing to 0-n lineups. Obviously, for lineups you'll do it the other way around! doc{ _id : lineup_y1 type : lineup .. .. lineups : [channel_x1, channel_x2] } An other possibility is embedding all related data in a master document, but that may be hard to handle depending on your use case. Cheers, >If I have a true many to many relationship that doesn't normalize easily, >what are some guidelines to make it couch-friendly? > >I've found that couch does a great job with one-to-many or one-to-one >relationship. It's easy to write a view that will return all the comments >for a given post, for example. > >But what about many-to-many? For example, I'm working with TV Guide data. >There are lineups and channels. A lineup can have a lot of channels, but the >channels can belong to several lineups. I then need to get what is playing >at 2:00 on every channel in my lineup. > >Thanks Markus Jelsma - Technisch Architect - Buyways BV http://www.linkedin.com/in/markus17 050-8536620 / 06-50258350