MongoDB for BI use

泪湿孤枕 提交于 2019-12-12 01:58:40

问题


Actually we want to use MongoDB for some BI processing and we don't know which schema is more suited in our case to get the job done. Imagine we got 100 000 data describing sales of a certain network, do we have to put all this data in one array? (like this)

{
   "_id" : ObjectId()
   "dataset" : "set1",
   "values" : [
                  {"property":"value_1"},
                     .
                     .
                     .
                     .
                  {"property":"value_100000"}
              ]
}

Or for each entry a document? (like this)

{"_id: ObjectId(), "property":"value_1"}
                     .
                     .
                     .
{"_id: ObjectId(), "property":"value_100000"}

Or simply what is the ideal way to scheme this use case?


回答1:


Embedding is better for :

  • Small subdocuments
  • Data that does not change regularly
  • WHen eventual consistency is acceptable
  • Document that grow by a small amount
  • Data that you'll often need to perform asecond query to fetch
  • Fast reading speed

References are better for

  • Large subdocuments
  • Volatile data
  • When immediate consitency is necessary
  • Document grow with a large amount
  • Data that you often exclude from document
  • Fast write speed

-From 《Mongodb Definitive Guide》

Reference is something like {'_id':ObjectId("123"),'cousin':ObjectId("456")} It refers to his cousin through its ObjectId something like foreign key in SQL.



来源:https://stackoverflow.com/questions/26392285/mongodb-for-bi-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!