这个问题不一定是 Couchbase 2.0 开发预览版特定的,但我认为它可能有助于人们调查新的 Couchbase 产品。
我正在寻找有关数据建模的建议。我们正在调查 Couchbase,以期可能将其用于实时分析。
但是,我找不到任何关于如何最好地为现实世界数据建模的文档。
我将提出一个场景,如果社区可以帮助我或讨论一些关于如何建模的想法,那会非常有用吗?
请注意,这不代表我们的产品,我并不是要求人们为我们解决我们的建模问题,这个问题更适合讨论
让我们假设客户在特定日期/时间购买产品,产品包含 ID、名称、描述和价格等信息,购买是在某个日期执行的。
最初的要求是能够计算两个日期之间的所有购买。任何 1 天都可能有超过 100,000 次购买 - 这是一项相当大的业务;)
如果任何语法不正确,请告诉我 - 欢迎所有建议/帮助。
如果我们像这样对数据进行建模(这可能完全不正确):
用产品购买
{
"_id" : "purchase_1",
"_rev" : "1-1212afdd126126128ae",
"products" : [
"prod_1" : {
"name" : "Milk",
"desc" : "Semi-skimmed 1ltr",
"price" : "0.89"
},
"prod_7568" : {
"name" : "Crisps",
"desc" : "Salt and Vinegar",
"price: "0.85"
}
]
"date" : "2012-01-14 14:24:33"
}
{
"_id" : "purchase_2",
"_rev" : "1-1212afdd126126128ae",
"products" : [
"prod_89001" : {
"name" : "Bread",
"desc" : "White thick sliced",
"price: "1.20"
}
]
"date" : "2012-01-14 15:35:59"
}
因此,鉴于该文档布局,我们可以看到每次购买,我们可以看到该购买中的产品 - 但是我们如何计算两个日期之间的所有购买?另外,您如何按日期降序查看两个日期之间所有购买的日志?
Is this something Couchbase is suited for?
There might be hundreds of thousands of purchases between two dates and the customer doesn't like to wait for reports….as I'm sure everyone has experienced ;)
Would it be best to use the incr functions and if so how would you go about modelling the data?
Many thanks to anyone that reads this - I hope to expland on this further giving more examples of real world modelling problems if possible.
James