incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marian Steinbach <>
Subject Document design: Logging accesses to an item by a user
Date Sat, 12 Nov 2011 20:26:58 GMT

I'm trying to think in CouchDB documents (coming from an SQL
perspective) and I am wondering how I should set up my documents to
represent the following.

I have users who play songs as often as they want. Whenever they
access a song, in the SQL world I add a record to a song_access table
that stores user id, song id and date/time. And there are of course a
users and a songs table.

In the CouchDB world, I find it reasonable to have both a User
document and Song document. But where should I store song accesses?

- Should it be on the User as a dict of song_id and timestamp (or vice versa),
- or should ie be on the Song with a user id and timestamp?
- or would it be worthwhile to do such a thing in a third document
SongAccess, which has one user id, one song id and possible multiple

The list of song accesses per user and also per song can grow very
large of course. Is this a good reason to leave it out of User/Song?

I would later need a view that lists all songs heard by a user in
chronological order.

The same design problem I have for ratings, although here I have song
id, user id, date/time and score.

Thanks for ramping me up!


View raw message