For multiple reasons, I'm currently considering moving to a NoSQL DB to store/manage a set of "scorecards". As scorecard is a simple table, with rows for regions and columns for metrics/indicators. As simple scorecard document for one month could look like this:
{
"month": 1,
"headers": ["Region", "# of page views", "# of unique visitors"],
"data": [
["Region 1", {"value": 1000, "previousValue": 800, "arrow": "up" }, {"value": 100, "previousValue": 110, "arrow": "down"}],
["Region 2", {"value": 500, "previousValue": 600, "arrow": "down" }, {"value": 10, "previousValue": 11, "arrow": "down"}]
]
}
resulting in this rendered table:
| Region | # of page views | # of unique visitors |
|----------|-----------------|----------------------|
| Region 1 | 1000 (↑) | 100 (↓) |
| Region 2 | 500 (↓) | 10 (↓) |
Every month, a new scorecard will be uploaded, i.e. a new document gets created. This scorecard might have a different structure, e.g.
{
"month": 2,
"headers": ["Region", "# of page views", "# of comments"],
"data": [
["Region 1", {"value": 1100, "previousValue": 1000, "arrow": "up"}, {"value": 5, "previousValue": null, "arrow": null}],
["Region 3", {"value": 1500, "previousValue": null, "arrow": null},{"value": 1, "previousValue": null, "arrow": null}]
]
}
resulting in
| Region | # of page views | # of comments |
|----------|-----------------|---------------|
| Region 1 | 1100 (↑) | 5 (-) |
| Region 3 | 1500 (-) | 1 (-) |
When I now receive an update for the month 1 scorecard, I also need to update the previousValue
(and the arrow
) property in the month 2 scorecard. Given that the structure might have changed, how can I do this update most efficiently? How can I "linked" the cells?
In a RDBMS, I would have normalized the values in another table and just linked the valueIds. However, as any scorecard can have a lot of values, I assume that storing the valueIds in the scorecard documents and retrieving all values in a second step is really inefficient?!
I have not decided on the NoSQL DB provider. Current favorite is CouchDb, but can also be MongoDB or DocumentDB. The backend is implemented in ASP.NET WebAPI.