Search code examples
nosqlcouchdbdocument-storage

Limit to appending children to a document in NoSQL?


When an example of an object owning many children is given with a document database (like couchdb) it is always recomended that the children be appended to the parent object. In the case of a blog post, this means that you add all the comments as children of the parent blog post object.

post
{
    title: '',
    text: '',
    comments:[...]
}

However, don't you run into limits fairly quickly doing this? What if you're post has 800 comments on it? Wouldn't that be a huge waste of bandwidth and processing if you only showed 100 comments per page (though some people show all the comments on a single page). The same with forum threads or anything else that might have a large number of children.

  • Is there a better way to handle this?
  • Is there a limit on the size of objects?
  • How does MVCC play into this since the whole object is created again on each update (each new comment) possibly filling the database with 800 copies of the blog post in a short time?

Solution

  • While browsing some other SO questions I found a link to a blog post that explains the correct way to handle this using a more complex view that can solve these problems. Though this solution is specific to couchDB.