The database ultimately stores data, so first of all, you need to know what time series data includes and what form it is.
The most basic information of time series data is indicators. As shown below:
27.5
27.6
27.3
......
But only indicators are not enough, because indicators are just a bunch of numerical values. What do these numerical values mean? This leads to another dimension, the indicator name. The index name is the meaning of the index, such as: temperature, speed, humidity, etc.
Therefore, the reversed timing data is as follows:
温度:27.5℃
温度:27.6℃
温度:27.3℃
......
With the indicator name and indicator value, a new question is brought about what time the indicator is at. Because time series data is based on time series data, there is no meaning without time. Each index value is the collection result of a certain time point, so it must also be accompanied by timestamp information.
Therefore, the updated timing data is as follows:
时间:2021-11-16 13:57:13,温度:27.5℃
时间:2021-11-16 13:57:14,温度:27.6℃
时间:2021-11-16 13:57:15,温度:27.3℃
......
With time, there is still one last question left, namely who sent the indicator. The index data is generated by the acquisition device, and the acquisition device itself will carry many identifiers and labels, so the complete form of the timing data is as follows:
气象传感器,型号1,编号0001,北京市,怀柔区,时间:2021-11-16 13:57:13,温度:27.5℃
气象传感器,型号1,编号0001,北京市,怀柔区,时间:2021-11-16 13:57:14,温度:27.6℃
气象传感器,型号1,编号0001,北京市,怀柔区,时间:2021-11-16 13:57:15,温度:27.3℃
......
After knowing the form of timing data, we need to consider how timing data is stored. At present, there are two types of timing data storage solutions:
Relational models are based on traditional relational databases. In a relational model, you need to define the schema, that is, the data table. After the table pattern is determined, the modification cost is higher. Taking the timing data just now as an example, in the relational model, you can create a data table of the following pattern:
Equipment ID | Temperature | Wind power | Humidity | Time stamp |
---|---|---|---|---|
Meteorological sensor, model 1, number 0001, Beijing, Huairou District | 29.2 | 3.2 | 55 | 2021-11-16 13:57:13 |
Meteorological sensor, model 2, number 0010, Shanghai, Chongming District | 21.5 | 8.5 | 35 | 2021-11-16 13:57:13 |
MatrixDB uses a relational model.
Non-relational models usually use the Key-Value pattern, with the index value as Value and the others as Key. Taking the timing data just now as an example, in the non-relational model, it can be stored as follows:
Key | Value |
---|---|
Meteorological sensor, model 1, number 0001, Beijing, Huairou District, time 2021-11-16 13:57:13, temperature | 29.2 |
Meteorological sensor, model 1, number 0001, Beijing, Huairou District, time 2021-11-16 13:57:13, wind power | 3.2 |
Meteorological sensor, model 1, number 0001, Beijing, Huairou District, time 2021-11-16 13:57:13, humidity | 55 |
Meteorological sensor, model 2, number 0010, Shanghai, Chongming District, time 2021-11-16 13:57:13, temperature | 21.5 |
Meteorological sensor, model 2, number 0010, Shanghai, Chongming District, time 2021-11-16 13:57:13, wind power | 8.5 |
Meteorological sensor, model 2, number 0010, Shanghai, Chongming District, time 2021-11-16 13:57:13, humidity | 35 |
...... |
The representative products of the non-relational model timing database include: OpenTSDB, InfluxDB, etc.
There are the following differences between relational models and non-relational models: