I have only used relational databases before. I read some mongodb books but I am still a little confused. Regarding the multi-layer nesting of mongodb,
The following table is an excel table that needs to be made into a database. I directly used mongodb for multi-level nesting
According to this table, if you directly create the mongodb nesting format, you need 4 levels of nesting. The json data is as follows :
{
"_id" : ObjectId("5858f844d5155de57df5efb3"),
"SITEID" : 1,
"ZONE" : "市南区",
"SITENAME" : "万象城机房",
"ZADDRESS" : "山东路10号",
"CLASS" : "D",
"LNG" : 120.339943,
"LAT" : 36.089903,
"SITE" : "",
"COSTINFO" : [
{
"RENT":[
{
"RENTALAGREEMENTNO":"协议标号",
"RENTPRICE":"3万",
"CONTRACTPERIOD":"1年",
"EXPLANATION":"暂时还没有"
}
],
"POWERRATE":[
{
"supply":"业主转供",
"ELECAGREEMENTNO":1234,
"PRICEOFELEC":1,
"METERLOCATION":"一楼电力室",
"ELECBILLPAYMENTCYCLE":"年付"
}
]
}
]
}
Please help to see if there are any errors in building the database in this way. Will there be any problems with subsequent data maintenance and query statistics? Thank you.
It is recommended to consider the following aspects before further modifying the data model:
1. What will be the main inquiry method in the future?
2. What will be the main statistical method in the future? Design data models for the main query/statistical methods.
3. What is the method/frequency of data update?
4. How big is the amount of data?
In addition to the basic data model, you also need to consider the establishment of indexes.
For reference!
Love MongoDB! Have Fun!
If the internally nested information is independent information and will be used repeatedly, you can try the implementation of DBRef, which will be more convenient when modifying the information