So, in my application I currently am receiving and storing some data,the structure currently is based around this:
- Each application has a number of devices
- Each device has incoming data from its sensors
- Each sensor has a type (e.g. temperature/humidity/etc)
Initially, I had wanted to find a solution to store the data dynamically into one table for all data, with a model that might look like this:
time = models.DateTimeField()
sensor = models.ForeignKey(Sensor, on_delete=models.CASCADE)
data = ???
Now, each sensor is connected in the models to all the details (including the application, the sensor hardware information and other API-related information for connecting to said sensors), however, for the data I looked up a number of options but I have yet to find one that feels sufficient, some of the options I explored are:
Storing the data in a dictionary and storing that in a model as per the answers in Here
Having separate tables and somehow calling the models later when storing data using the method here, in addition to some system with inheritance such as discussed here
Something similar to this using dynamic fields
I am currently using mySQL, and I saw some other solutions that might work using PostgreSQL for example, but I would like to avoid switching databases if there is another option.
I just feel there must be a better more clean solution for this, as it feels like a straightforward implementation. In a sense most of those implementation either feel too hack-y and inefficient especially considering that I will be storing a large amount of data (A larger number of sensors sending data continuously to the server), or do not allow queries on the sub-data.
Are there any other better implementations for my application? If not, which one of those implementations is best for me to focus on?