有一组 800 多个气象监测点的 5 年的 8 大类型数据的气象数据集,如果想存储到 MongoDB 的话,文档应该怎么设计最好呢?
我现在想到的两种格式不知道哪种比较合适,或者说有更好的?
第一种
以城市为单位,每日数据作为数据全部存储在对应城市的文档里,最终文档数量和气象监测点数量相同
{
city:"北京",
data:[
{
type:"温度",
data:[
{
date:2017-3-16;
detaildata:xxx
},
{
date:2017-3-17;
detaildata:xxx
}
]
},
{
type:"湿度",
data:[
{
date:2017-3-16;
detaildata:xxx
},
{
date:2017-3-17;
detaildata:xxx
}
]
}
]
}
第二种
以城市和日期为单位,单个文档存储每日的数据,最终文档数量等于气象监测点数量乘以 5 乘以 365
{
city:"北京",
date:2019-3-17,
data:[
{
type:"温度",
detaildata:xxx
},
{
type:"湿度",
detaildata:xxx
}
]
}