Key concepts
Nibble stores data as a series of values each of which is associated with a point in time. A value is is a floating point number which can optionally be tagged with extra information that can later be used during querying. It is usually straight forward to spot the type of data that can represent a time series. To illustrate this, we will borrow from the example provided on the InfluxDB site.
time | butterflies | honeybees | location | scientist |
2015-08-18T00:00:00Z | 12 | 23 | 1 | langstroth |
2015-08-18T00:00:00Z | 1 | 30 | 1 | perpetua |
2015-08-18T00:06:00Z | 11 | 28 | 1 | langstroth |
2015-08-18T00:06:00Z | 3 | 28 | 1 | perpetua |
2015-08-18T05:54:00Z | 2 | 11 | 2 | langstroth |
2015-08-18T06:00:00Z | 1 | 10 | 2 | langstroth |
2015-08-18T06:06:00Z | 8 | 23 | 2 | perpetua |
2015-08-18T06:12:00Z | 7 | 22 | 2 | perpetua |
The above table shows the number of butterflies and honeybees collected by scientists at different locations. We can easily spot that both bufferflies and honeybees have values and are associated with a timestamp. It is perhaps less clear at first what the location and scientist columns are but by just looking at the data we can see they are not time series values but extra information we can store about the number of butteflies or honeybees we record. Therefore, the way we interpret this data for storage in Nibble is we will create two separate time series: bufferflies and honybees and record the values with their timestamps together with each value tagged with location and scientist.
butterflies
[
{"timestamp": 1439856000000000, "tag": [{"location":"1"},{"scientist":"langstroth"}], "value": 12},
{"timestamp": 1439856000000000, "tag": [{"location":"1"},{"scientist":"perpetua"}], "value": 1},
{"timestamp": 1439856360000000, "tag": [{"location":"1"},{"scientist":"langstroth"}], "value": 11},
{"timestamp": 1439856360000000, "tag": [{"location":"1"},{"scientist":"perpetua"}], "value": 3},
{"timestamp": 1439877240000000, "tag": [{"location":"2"},{"scientist":"langstroth"}], "value": 2},
{"timestamp": 1439877600000000, "tag": [{"location":"2"},{"scientist":"langstroth"}], "value": 1},
{"timestamp": 1439877960000000, "tag": [{"location":"2"},{"scientist":"perpetua"}], "value": 8},
{"timestamp": 1439878320000000, "tag": [{"location":"2"},{"scientist":"perpetua"}], "value": 7}
]
honeybees
[
{"timestamp": 1439856000000000, "tag": [{"location":"1"},{"scientist":"langstroth"}], "value": 23},
{"timestamp": 1439856000000000, "tag": [{"location":"1"},{"scientist":"perpetua"}], "value": 30},
{"timestamp": 1439856360000000, "tag": [{"location":"1"},{"scientist":"langstroth"}], "value": 28},
{"timestamp": 1439856360000000, "tag": [{"location":"1"},{"scientist":"perpetua"}], "value": 28},
{"timestamp": 1439877240000000, "tag": [{"location":"2"},{"scientist":"langstroth"}], "value": 11},
{"timestamp": 1439877600000000, "tag": [{"location":"2"},{"scientist":"langstroth"}], "value": 10},
{"timestamp": 1439877960000000, "tag": [{"location":"2"},{"scientist":"perpetua"}], "value": 23},
{"timestamp": 1439878320000000, "tag": [{"location":"2"},{"scientist":"perpetua"}], "value": 22}
]
An alternative way to handle the data is to store both butterflies and honeybees data into one time series. To do this we should add an additional tag to the values so that we can filter the data later on in queries. For example we could write the values as follows:
{"timestamp": 1439856000000000, "tag": [{"insect":"honeybees"},{"location":"1"},{"scientist":"langstroth"}], "value": 23},
Note how we added a tag to differentiate the type of insect. We would now have a larger time series to deal with so depending on the size of the dataset you can make a decision which of two approaches make more sense. If the dataset becomes large for one instance of nibbledb there is the option to scale using the nibblegw component.
Last modified 2yr ago