incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Reed <rangerr...@gmail.com>
Subject Design Question: What is a Good Model?
Date Tue, 08 Oct 2013 14:10:39 GMT
I'm extremely new to CouchDB, and to NoSQL and map/reduce in general.  I
was wondering, what is the best way to design what I'm trying to accomplish?

I'm writing an app, which will have a collection of (calendar) events,
created by users.  Users will be able to mark events created by other users
as favorites.

In a traditional database, I'd have at least 2 tables:
- an event table, with a column representing the user that created the event
- a "favorites" table, which maps a user to an event that he has favorited
- optionally, a user table with info about the user, and a unique ID that
can be used in lieu of username in the first 2 tables when making foreign
references

In the (web) app I'm writing, I've got the events in couchdb:

[{
   _id: whatever,
   type: 'event',
   summary: 'foo',
   description: 'bar',
   createdBy: 'RangerRick'
}]

But what is the best way to retrieve the "favorites" associated with a
specific user?  Do I just make a doc with an ID set to
"RangerRick-favorites" and retrieve it directly?  Do I just put individual
username -> _id entries in for each favorite?

I currently am doing the latter, which didn't seem like a big deal until I
had to pull just the list of events that match the favorites, and can't
figure out how to make a map/reduce that does it efficiently.

Do I just map anything that's a type=favorite or type=event and then...
reduce it somehow by putting them together?

-- 
Benjamin Reed a.k.a. Ranger Rick
Fink, KDE, and Mac OS X development

Blog: http://www.raccoonfink.com/
Music: http://music.raccoonfink.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message