If your use case closely follows the case in the blog post, then the
approach is still valid even if you need to store different time span. The
time span involved in designing a time-series solution is highly dependent
on what you need to do with the data you collected. The blog post solution
assumes that you need to see a summary of data for every minute, but also
need to store the detailed information every second.
1. Some sensors can sense at the same time different ‘things’ e.g.
temperature and humidity. Is it best to store the temperature and humidity
data in 2 separate documents in the same collection (or both
readings/values in the same document)? Additionally, it is possible the
time intervals for reading the values of temperature and humidity can be
It depends on how you want to use the data. If the temperature and humidity
- frequently used together, and
- collected at the same time interval (e.g. every second), and
- need to be summarized within the same timeframe (e.g. every minute)
then you could combine the two in a single document, for example:
- not frequently used together, or
- collected at different time intervals (e.g. every second for
temperature, every minute for humidity), or
- need to be summarized at different timeframe (e.g. every hour for
temperature, every day for humidity)
then storing temperature and humidity in two different documents may be a
Flexibility is also important: to have the possibility to easily add other
sensor types (e.g. for pH, etc).
MongoDB stores data in a flexible schema, so you can easily add more
measurements in your documents.
Other resources regarding schema design that you may find useful are: