我正在寻找一些关于使用 NoSQL CosmosDB 或相关技术设计应用程序的建议。
数据结构目前如下所示:
{
"accounts": [{
"name": "name1",
"type": "type1"
},
{
"name": "name2",
"type": "type2"
}
],
"categories": [{
"master": "mastername",
"child": [
"child1name",
"child2name"
]
},
{
"master": "mastername2",
"child": [
"child3name",
"child4name"
]
}
],
"charts": {
},
"grouping": [{
"2018": [{
"06": {
"property1": "value1",
"property2":"value2"
},
"07": {
"property1": "value2",
"property2":"value2",
"property3":"value3"
}
}]
}],
"ItemsList": [{
"id": "2018051720",
"dateMonth": "201807",
"property1": "value2",
"date": "17/07/2018",
"Description": "description2"
},
{
"id": "2018051720",
"datemonth": "201807",
"property1": "value1",
"date": "17/07/2018",
"Description": "description"
}
],
"id": "7b786960c93cc9a8"
}
目前,出于预算考虑,我决定拥有一个集合,其中包含您在上面看到的数据结构的倍数,就像它的列表一样。
我的问题是,这是一个好的设计吗?问的原因是以下元素会随着时间的推移而大幅增长。
项目列表和分组。
Itemlist 会随着用户添加而每月增长,Grouping 将针对每年和每月,每月一次,但随着 ItemList 项目的添加而更新。类别和帐户也可能会不定期地发生变化。
如果我在一个集合中有这个,我想也许我以某种方式具有以下结构:
// Main Object
{
"accounts": [{
"name": "name1",
"type": "type1"
},
{
"name": "name2",
"type": "type2"
}
],
"categories": [{
"master": "mastername",
"child": [
"child1name",
"child2name"
]
},
{
"master": "mastername2",
"child": [
"child3name",
"child4name"
]
}
],
"charts": {
},
"id": "7b786960c93cc9a8"
}
// Groupings list
{
"grouping": [{
"userid": "7b786960c93cc9a8",
"grouping": {
"2018": [{
"06": {
"property1": "value1",
"property2": "value2"
},
"07": {
"property1": "value2",
"property2": "value2",
"property3": "value3"
}
}]
}
},
{
"userid": "sfkjehffkjwhf34343",
"grouping": {
"2018": [{
"04": {
"property1": "value1",
"property2": "value2"
},
"05": {
"property1": "value2",
"property2": "value2",
"property3": "value3"
},
"06": {
"property1": "value2",
"property2": "value2",
"property3": "value3"
}
}]
}
}
]
}
// Item List List
{
"ItemLists": [{
"userid": "7b786960c93cc9a8",
"itemlist": [{
"id": "2018051720",
"dateMonth": "201807",
"property1": "value2",
"date": "17/07/2018",
"Description": "description2"
},
{
"id": "2018051720",
"datemonth": "201807",
"property1": "value1",
"date": "17/07/2018",
"Description": "description"
}
]
},
{
"userid": "sfkjehffkjwhf34343",
"itemlist": [{
"id": "2018051720",
"dateMonth": "201807",
"property1": "value2",
"date": "17/07/2018",
"Description": "description2"
},
{
"id": "2018051720",
"datemonth": "201807",
"property1": "value1",
"date": "17/07/2018",
"Description": "description"
}
]
}
]
}
正如你所看到的,我基本上会让主对象列表正常增长,然后是其他 json 对象,用于 itemlist 和分组,它可以从主对象独立增长,但它需要两次读取,甚至需要三个 RU为网站。基本上每个月只有 400 RU 的工作,它的用户群和对象不是很多吗?
在考虑金钱时最好的方法是什么,因为如果金钱没有问题,我可能会为每个集合使用一个集合,其中主要对象只是通过 Id 或其他东西引用另一个集合。
希望它有一点意义,在我的脑海里是这样的:)