Skip to content
Frederik Walk edited this page Mar 23, 2016 · 3 revisions

Rough overview over the database schema

Schema

The user database stores devices, sensors and measurements depending on the currently associated user. It is not possible to store anything without an associated user. Dropping a user, device or sensor from the database will cascade to all associated entities, i.e. dropping a user will delete everything down to all measurements belonging to that user.

Measurements

Measurements should be inserted into the measure_raw table in the raw they are output from the sensor. Those can then be aggregated by the do_aggregate() function in the database to averages of fixed time intervals. This will delete all values from the measurement_raw table and insert them as sum of all values and count of the values for a time interval into the measure_aggregated_ table for that time interval.

This also works for nonlinear increasing timestamps. A possible conversion factor stored for the sensor has no impact to measurement store, it is applied later in the back-end.

Groups

To be able to share measurements between a group of users, sensors and users can belong to one or many groups. Groups are stored in the groups table and have relationships to the users and sensors belonging to them. The user relationship also contains a is_admin flag, expressing that the user should be able to add and remove users to this group. If a sensor is shared with a group should be decided by the user to whom the sensor belongs. Deleting a group does remove all association to this group, but not users or sensors.

Virtual sensors and devices are explained here

Clone this wiki locally