SINGLE DOCUMENT VS SEPARATE DOCUMENT(Reference Documents)

Hi ,
Can someone clarify my doubt. That, Which I have to use Single document for storing all user information or linking multiple documents(separate) to main document. Both have their pros and cons.

Please tell for which scenario i have to use single document and separate documents. Consider, my requirement similar to storing user profile information and his friends list…

And also can someone guide regarding mutual friends in couchbase.

Thanks,
Prem

Hello.

Your single or separate doc design completly depends on your applicetion. If you have an app that will need all data in same time (i.e. display all account info in some table) you should use “single doc” approach - because you’ll get needed data with less requests to database. If you have an app that needs different parts of data in different cases - you should divide that “parts” and store them in separate docs. If you use “single doc” approach in this way, you’ll get a large data transfer overhead, you’ll transfer large amount of useless data. But when you need “all” data, you’ll need more than one request to gather it.

Also if you have some parts in that doc which can change in differrent places at the same time, yoou should also try to divide that parts to multiple docs.

couchbase gives a great example of separate vs all in one document.
http://www.couchbase.com/docs/couchbase-devguide-2.1.0/relating-documents-for-retrieval.html

Remember Cocuhbase also has a soft Limit of 20MB per document limit also.(You can increase it but its no a good idea)