Modelling Best Practices: Database vs Document Types? Model vs Plain Document?


I am new to Couchbase and I am interested in discovering the best way to model data using the Couchbase system. I am using Couchbase to build what I hope will become a massive user environment and I have many kinds of data. Some of the data is related while some other types of data tends to stand alone. For example lets say I have Customer and Order documents. Currently I am modeling the data with an element in the document that names what kind of document the data is. Then the other attributes of that document. So I have multiple documents types in the same database. What I was considering was if I am going about it the wrong way. In hazelcast we would create multiple maps and each map would have its own type of data stored in it. Perhaps I should create multiple databases and put one kind of document in each kind of database? I am interested in opinions on this.

The second question with data modeling has to do with validation. Right now I have entity classes that hide the document implementation from the other code in the system. Essentially I have applied a model over the documents and use that model for the rest of the app. I am wondering if this is overkill. The primary reason I have the model is to hide implementation from the users and to implement data validation. I know Couchbase supports a CBLModel but it requires too much permissiveness for me to consider as a valid paradigm. If I am to have a model I want to control what can be changed, not let everything be open and trust to good intentions. At any rate, are there ways to validate Couchbase document data built into the system? Also what have others done when it comes to validation. Model over document or raw document?

Thanks for your time.

No opinions on this?

I think @matthew may be able to give you some thoughts. He’s the author of a couple of blogs on data modeling.