This question is not necessarily Couchbase 2.0 develop preview specific however I think it may help people with investigation into the new Couchbase product.
I am looking for advice on data modelling. We are investigating Couchbase with a view to possibly using it for Realtime Analytics.
However I cannot find any documentation on how best to model real world data.
I shall propose a scenario and if the community could help me or discuss some ideas for how this could be modelled it would be very useful?
Note this is not representative of our product and I am not asking people to solve our modelling for us the question is more intended for discussion
Lets assume that customers make purchases of products at a particular date/time, products have information with them such as id, name, description and price, a purchase is performed on a date.
The initial requirement is to be able to count all purchases between two dates. For any 1 day there might be over 100,000 purchases - this is a pretty big business ;)
If any of the syntax is incorrect please let me know - all advice/help is welcome.
If we modelled the data something like so (which maybe completely incorrect):
Purchases with products
{
"_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"
}
So given that document layout we can see each purchase and we can see the products that were in that purchase - however how could we go about counting all the purchases between two dates? Also how could you see a log of all the purchases between two dates in date descending order?
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