I've just starting out with NoSQL (in my case CouchDB) and can't seem to answer what I believe should be a simple question, on what the common practice is around creating a new document vs. appending data to an existing one.
I currently have a database per user (meaning that I can give users access ONLY to the data they own).
So at the top level, my CouchDB looks like:
- UserA_db
- UserB_db
Say I have a simple notebook application, where each user can have 1 or more notebooks, each containing 1 or more notes.
Is the idea that you add a single document per notebook, like so:
- UsersA_db
- NoteBook1_doc = { notes: [ { notebody: 'foo' }, { notebody: 'bar'} ] }
- NoteBook2_doc = { notes: [ { notebody: 'baz' }, { notebody: 'boo'} ] }
OR, is everything supposed to be completely flat, irrespective of what the document is, what it contains or what it relates to?
- UsersA_db
- NoteBook1_doc = { id: 1 }
- Note1_doc { id: 1, parentBook: 1, notebody: 'foo' }
- Note2_doc { id: 2, parentBook: 1, notebody: 'bar' }
- SomethingCompletelyDifferent_doc { id: 1, text: 'all cows eat grass' }
- AccountInformation_doc { name: 'Bob', age: 34 }