I am trying to understand some key design principles for a document db.
- Assume i have a natural key for users, so upon registration i create a uid
and create the user key:
To create a relationship with another user/document, i add a separate document with the key
which has the connected friends in the JSON document
The user json document has a “no_friend” field which i increase for every accepted friend. As such, i already know they keys i need to request for display friends of user X when i get the user document. Thus simply do a:
Is this a good,scalable, data model for relationships ?
Is this operation more or less expensive (time wise) than creating a view to emit friends type documents that belongs to u:1 ?
I guess the question is when to apply views if it can be access by keys, never ?
- Natural key seems very logical, when should i not use natural keys as in the example above ? I know some are using UID v4 or any other random keys.