Dynamic typing converter from the incoming sensory data to the database #19

Closed
opened 2026-03-27 16:03:08 +00:00 by Andras · 3 comments
Owner

Right now, a table is created in the sensors database for each sensor that comes in via MQTT.

The created database table includes a timestamp and a payload.

We need a solution to create the table with all the necessary fields for the incoming data: i.e., determine what kind of data it is and create columns with the correct data types.

May we need some form of a Strategy design pattern to handle this?

Right now, a table is created in the sensors database for each sensor that comes in via MQTT. The created database table includes a timestamp and a payload. We need a solution to create the table with all the necessary fields for the incoming data: i.e., determine what kind of data it is and create columns with the correct data types. May we need some form of a Strategy design pattern to handle this?
Collaborator

We've done some research on this today and we've come up with some ideas that we're gonna experiment with over the weekend.

We've done some research on this today and we've come up with some ideas that we're gonna experiment with over the weekend.
Collaborator

I've made some progress(or experiments rather, if you prefer to call it that), but I'm not entirely sure how we want to proceed with this.

I spent some time trying to have the data objects themselves control the SQL query by storing an array of strings that would declare what data type each property of the objects would have in the database.
The same thing could also be done by just using a single string and then having the middleware split it up and combine that string with the properties into an SQL-query.

Or, if we're not too picky about the datatypes we want to use in the database, we could just have each datatype on the objects (bool, string, int) correspond to a reasonably fitting SQL datatype. There could be some minor issues with this like how to handle DATETIME, but that could possibly be handled in the middleware.

I've also updated the middleware to output more information about the payload(s), which could prove useful when working on this area. (see picture)

Maybe I've completely misunderstood the issue. If so, please enlighten me.

I've made some progress(or experiments rather, if you prefer to call it that), but I'm not entirely sure how we want to proceed with this. I spent some time trying to have the data objects themselves control the SQL query by storing an array of strings that would declare what data type each property of the objects would have in the database. The same thing could also be done by just using a single string and then having the middleware split it up and combine that string with the properties into an SQL-query. Or, if we're not too picky about the datatypes we want to use in the database, we could just have each datatype on the objects (bool, string, int) correspond to a reasonably fitting SQL datatype. There could be some minor issues with this like how to handle DATETIME, but that could possibly be handled in the middleware. I've also updated the middleware to output more information about the payload(s), which could prove useful when working on this area. (see picture) Maybe I've completely misunderstood the issue. If so, please enlighten me.
Collaborator

Due to a lack of communication we both effectively created the same thing, albeit in different ways. We're working on solving it now.

Due to a lack of communication we both effectively created the same thing, albeit in different ways. We're working on solving it now.
Sign in to join this conversation.
No milestone
No project
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Andras/BoundlessFlowCampus2K#19
No description provided.