Logical Data Structures
Sun Mar 14 2021
Envision your full blown scaled up use case for your IoT system before starting your IoT implementation. Not that you cannot prototype at speed or test stuff, but getting a well thought through data structure at an early stage will save you time in the future.
A typical IoT project will often have sensory data coming from the exact same type of devices from different locations. You will also most likely at some point introduce new devices collecting other data (often from similar locations) used to expand your data foundation for better decision support.
In Dimension Four we introduce a generic structure which gives you a good framework for structuring your data and data sources. A quick introduction to this framework is given in our developer guide.
Just to give you a feel - we typically recommend that you create a tenant for your project, then establish a space structure that fits your IoT solution. Then you add points into the spaces to feed you with signals from the different sensors on the devices.
If you create a fairly generic and replicable structure for your IoT project, this will simplify the logical interaction with this data for the future and provide a good foundation for expanding your project with perhaps millions of devices hooked up in the future.
With a good structure your data analysts and front-end developers will have easy access to the collected and structured data through our GraphQL API´s.
Find below an example of a simple logically built data structure for IoT. In this structure we are basically setting up for monitoring a house. We set up separate spaces for each room. By doing this we can easily simplify work with the incoming data, both for analytical purposes and when showing this in for instance a web interface.
{
"data": {
"spaces": [
{
"name": "Bathroom",
"points": [
{
"name": "Toilet",
"mac": "AB:CD:EF:GH:IJ:15"
},
{
"name": "SmartSensor",
"mac": "AB:CD:EF:GH:IJ:35"
}
]
},
{
"name": "Kitchen",
"points": [
{
"name": "KitchenCorner",
"mac": "AB:CD:EF:GH:IJ:12"
},
{
"name": "KitchenBench",
"mac": "AB:CD:EF:GH:IJ:13"
},
{
"name": "SmartSensor",
"mac": "AB:CD:EF:GH:IJ:30"
}
]
},
{
"name": "LivingRoom",
"points": [
{
"name": "Sofa",
"mac": "AB:CD:EF:GH:IJ:14"
},
{
"name": "TV",
"mac": "AB:CD:EF:GH:IJ:20"
},
{
"name": "SmartSensor",
"mac": "AB:CD:EF:GH:IJ:25"
}
]
}
]
}
}
Find below also an example where we want to monitor all incoming signals from the rooms in the house, but do not want to see any “SmartSensor” signals and also not any signals from the “Kitchen”.
We define and execute this query..
query {
spaces(where: { name: { _NE: "Kitchen" } }) {
name
points(where: { name: { _NE: "SmartSensor" } }) {
name
}
}
}
..which returns this result..
{
"data": {
"spaces": [
{
"name": "Bathroom",
"points": [
{
"name": "Toilet"
}
]
},
{
"name": "LivingRoom",
"points": [
{
"name": "Sofa"
},
{
"name": "TV"
}
]
}
]
}
}