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 3E9AB10890 for ; Wed, 9 Oct 2013 21:24:21 +0000 (UTC) Received: (qmail 30566 invoked by uid 500); 9 Oct 2013 21:24:19 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 30536 invoked by uid 500); 9 Oct 2013 21:24:18 -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 30528 invoked by uid 99); 9 Oct 2013 21:24:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Oct 2013 21:24:18 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [80.108.101.178] (HELO mail.meredrica.org) (80.108.101.178) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Oct 2013 21:24:13 +0000 Received: from android-af9ab504e3b37868 (chello080108101178.24.11.vie.surfer.at [80.108.101.178]) (Authenticated sender: stuff@meredrica.org) by mail.meredrica.org (Postfix) with ESMTPSA id A92406A093 for ; Wed, 9 Oct 2013 23:23:51 +0200 (CEST) User-Agent: Kaiten Mail In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: Design Question: What is a Good Model? From: "Florian Westreicher Bakk.techn." Date: Wed, 09 Oct 2013 23:23:49 +0200 To: user@couchdb.apache.org Message-ID: X-Virus-Checked: Checked by ClamAV on apache.org Quick question: why would a complex key be required? Could we not emit (userid, eventid) and be happy? Filippo Fadda wrote: >Mark is right, you need 3 different document types. The Favorite >structure will have: _id, _rev, userId, eventId, timestamp (it's always >a good idea to store the timestamp because you might use to sort data >eventually). > >If you have a list of events and you want show a 'star' on every event >starred by the current user, you have to make a query (one for each >event unfortunately) using a complex key [eventId, userId]. > >This is the best approach to avoid conflicts, because your events and >your users will never change when a new event has been added to the >user favorites. > >Bye > >-Filippo > >On Oct 9, 2013, at 7:36 PM, Mark Deibert wrote: > >> To follow on: sounds like you need 3 docs "events", "favorites" and >"users" >> or just use the built in "_users" which may be better. Do your best >to keep >> your docs denormalized as much as possible/sensible. Also keep >something in >> mind, with no-sql dbs, you will frequently have to query multiple >views in >> a sequence to effect relationships/joins. And definitely lookup views >with >> compound keys. This is how you will "join". >> >> >> On Wed, Oct 9, 2013 at 1:23 PM, Mark Deibert >wrote: >> >>> The reduce function is for aggregating data in a view. You'll need a >view >>> with a compound key to "join" two types of documents. Lookup >compound keys >>> in views. I'll post again later if you need more help. -- Sent from Kaiten Mail. Please excuse my brevity.