Should I make primary key of my record-set as the Document ID of document

Hi All,

I am migrating from an RDBMS background to NOSQL. So after all de-normalization we have come up with a set of document for each entity. In this all child entities are collections in JSON document. But there are some issues:-

  1. Bucket is more like a table so we will be keeping all the data in one table, which means keeping a type Column/key in the document. For every search or document retrieval we will have to keep that type into consideration. We can also have different buckets for different bigger set of documents but then recommendation to keep number of bucket is 5 which can be less and we may have to go for more clusters. Now If I keep all data in a single bucket I will have to create a view where type and primary key will be a combined key and complete document as value. but will it be fast enough in retrieving data compared to retrieving data from document Id.

  2. Lets assume if we keep different bucket for different manifests of documents and keep the number of buckets as recommended, then can we keep the primary key value as the document ID, As I understand searching a document by document ID is fastest way to get it.
    Should I make the primary key value (a GUID) as the documents id ("_id"), Will it change whenever a revision of the document is posted by the client. Or should I keep this value as a key inside the document.

And if it (Document ID) doesn’t change how revisions are kept in couch base ?

Please help me in deciding the modeling of data as whatever I have read didn’t helped me much.

Can you suggest some books on couch base mobile framework where I can understand internal way of working in this wonderful technology.

Regards
Pankaj Sharma

_id will not changed , revision of document (_rev) will be generated by CBL that you can not change it directly.

1 Like

Does it mean Revision documents are not kept as separate documents and all revision is saved inside the document?

Can you provide a link to better understand revisions. Or a good book will be awesome too .

FYI about revision