Understanding the sensor metadata

The metadata about all the sensors across all locations is available to us in a relational database. In our example, we have stored it in MySQL. This type of metadata can be stored in any relational database other than MySQL. It can also be stored in Elasticsearch in an index. 

The metadata about sensors primarily contains the following details:

  • Type of sensor: What type of sensor is it? It can be a temperature sensor, a humidity sensor, and so on.
  • Location-related metadata: Where is the sensor with the given sensor ID physically located? Which customer is it associated with?

This information is stored in the following three tables in MySQL:

  • sensor_type: Defines various sensor types and their sensor_type_id:

sensor_type_id

sensor_type

1

Temperature

2

Humidity

  • location: This defines locations with their latitude/longitude and address within a physical building:

location_id

customer

department

building_name

room

floor

location_on_floor

latitude

longitude

1

Abc Labs

R & D

222 Broadway

101

1

C-101

40.710936

-74.008500

  • sensors: This maps sensor_id with sensor types and locations:

sensor_id

sensor_type_id

location_id

1

1

1

2

2

1

Given this database design, it is possible to look up all of the metadata associated with the given sensor_id using the following SQL query:

select 
st.sensor_type as sensorType,
l.customer as customer,
l.department as department,
l.building_name as buildingName,
l.room as room,
l.floor as floor,
l.location_on_floor as locationOnFloor,
l.latitude,
l.longitude
from
sensors s
inner join
sensor_type st ON s.sensor_type_id = st.sensor_type_id
inner join
location l ON s.location_id = l.location_id
where
s.sensor_id = 1;

The result of the previous query will look like this:

sensorType

customer

department

buildingName

room

floor

locationOnFloor

latitude

longitude

Temperature

Abc Labs

R & D

222 Broadway

101

Floor1

C-101

40.710936

-74.0085

 

Up until now, we have seen the format of incoming sensor data from the client side. We have also established a mechanism to look up the associated metadata for the given sensor.

Next, we will see what the final enriched record should look like.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.156.60