开发者

How do handle relations in document stores

开发者 https://www.devze.com 2023-03-27 06:06 出处:网络
I do understand that relations are not really needed in document stores, but for some things they can still be useful. Or am I wrong (snowed in on RDBMS)?

I do understand that relations are not really needed in document stores, but for some things they can still be useful. Or am I wrong (snowed in on RDBMS)?

For instance:

Let's say that I got a bunch of files an开发者_运维问答d their revision history:

File
   Name
   Path
   CreatedBy
   .. etc ..
   Revision
      Date
      Info 
      CreatedBy

Should I add the User object to CreatedBy for the file and all revisions, or should it be an ID referencing the User document? What's the common practice?


Should I add the User object to CreatedBy for the file and all revisions, or should it be an ID referencing the User document? What's the common practice?

Both MongoDB and CouchDB have articles regarding this topic and I would say it depends on your scenario, data and DB system you using. If the data you consider to embedd or reference are big, you should reference it because for example CouchDB doesn't support (as far as I know) returning only part of the document in case it's large and you want to retrieve only basic/selected structure. On the other hand embedding can help you during querying since you don't have to look up for the referenced documents, but this really depends on the system you are using.

0

精彩评论

暂无评论...
验证码 换一张
取 消