couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luis Gomez <>
Subject Modeling document structures
Date Wed, 10 Mar 2010 19:55:02 GMT
Hello all,

I've been working/playing with couchdb for a few weeks now and would like to
pose a question here that is not so much about the technical details of cdb
but more about document-oriented database design.

Consider the following objects top-level (ie: types of documents): "user",
"league", "card" and "game". And here are the relationships:

1. Leagues belong to one user.
2. Leagues have members (ie: users).
3. Users have one or more leagues they own.
4. Users are members of zero or more leagues.
5. To subscribe to a league, a user must fill out a card and summit it to the
    league. Note; the cards are the users' way of submitting their game
    predictions to a league and are required for membership.

This is a fantasy league management system. But you probably figured that out

I modeled and created the objects and relationships very quickly in mysql but
could not stop thinking about how easy it would be to do the same in cdb. So
here I am.

The question is, what is the criteria or more reasonable method for deciding
how to model objects in a document-oriented database system like CouchDB? I
was going to have the same objects be document types but, as I designed the
application, I thought it would make sense to keep the objects the user owns
with the user. This way I end up with a single document type (user) and merge
what would have been multiple requests into one with all the user's data in

Look at how I was approaching this in a more traditional way:

And now look at how I'm imagining I can do this:
(there's an example in there).

Notice how I use URLs to link cards to leagues. <user._id>/<league.slug>.


1. Do you think using URLs like these in a database makes sense? If not, any
2. What's your preferred approach to modeling a database in couchdb. Being
    schema-free sounds great but there's is probably no "right" answer to this
    question and I'd like to get ideas and opinions.

More than this particular example, I'd like to start a discussion and see how
the pros are doing it.



View raw message