我应该嵌套记录数据还是将其放在该根文档上? [英] Should I nest my record data or put it right on that root document?

查看:55
本文介绍了我应该嵌套记录数据还是将其放在该根文档上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在使用C#和CosmosDB.使用我目前的方法,我的数据最终成为与其他必需的文档元数据(例如id,_self,_attachments等)相邻​​的同级属性.我看到这些数据都带有下划线前缀,因此不太可能与之冲突. 无论如何,我的字段和id都是有用的,但是当您仅查看JSON记录数据时,它看起来就显得杂乱无章.

I'm using C# and CosmosDB. With my current approach, my data ends up as sibling properties right next to the other required document meta data, such as id, _self, _attachments, etc. I see those are prefixed with underscores, so it's unlikely to clash with my fields and id is useful regardless, but it looks kind of unorganized when you just look at the JSON record data.

如果我的数据域中的所有内容都嵌套在"data"之类的东西下,它将看起来更好,并且可能是一个不错的约定.

It'd look nicer and perhaps be a nice convention if everything from my data domain were nested under something like "data", etc.

这是个坏主意还是有任何理由不这样做?

Is this a bad idea or are there any reasons not to do this?

推荐答案

瑞安,

请查看以下文档:建模NoSQL数据库的文档数据

在您的情况下,同级属性被称为实体",这些值可以嵌入,也可以存在于完全不同的分区中.这 混合数据模型通常是最好的选择,因为它允许根据吞吐量需求在某些实体中嵌入某些实体,同时引用其他实体.

In your case, sibling properties are referenced as 'entities' and these values can either be embedded or they can exist in an entirely different partitions. The Hybrid data model is usually the best option, as it allows for embedding some entities while referencing other's in different partitions, based upon throughput needs.

如果您还有其他问题,请告诉我们.

Please let us know if you have additional questions.

此致

迈克


这篇关于我应该嵌套记录数据还是将其放在该根文档上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆