I need to store daily stock closing prices as well as tick data in MongoDB. How would you design such a schema? For daily prices I would be tempted to have one document for each stock symbol, e.g.
{
symbol: "AAPL",
quotes: {
{
date: '2014-01-01',
values: { open: 1, high: 1, low: 1, close: 1, volume: 100 }
},
{
date: '2014-01-02',
values: { open: 1, high: 1, low: 1, close: 1, volume: 100 }
}, ...
}
}
For tick data I could do something like the above with one subdocument per hour with an array of ticks.
However, considering the maximum document size is only 16MB I believe the limited would be reached very fast, especially for tick data.
I am aware of this approach http://blog.mongodb.org/post/65517193370/schema-design-for-time-series-data-in-mongodb. Would that be a good approach? I.e. one document per symbol per day?
So, how would you design the schema for daily prices and tick data, respectively?
I think you are on the right track.