Data Modelling for IoT based application in Apache Cassandra

0 votes

I'm using Apache Cassandra in an IoT application, where I plan to create a device abstraction for users to define their devices with required sets of attributes. And, for each attribute, any user can only define specific properties like name, data type, minimum value, maximum value, etc.

Like say, here are the examples for some devices:

Device: 
Vehicle
Attributes it can have:
Speed (name = speed, data type = double, minimum value = 0, maximum value = 300)
Latitude (name = latitude, data = double, minimum = -90, maximum = 90)
Longitude (name = longitude, data = double , minimum = -180, maximum = 180)

Device: 
Temperature Sensor
Attributes it can have:
Current Temperature (name = Current Temperation, data type = double, minimum = 0, maximum = 300)
Unit (name = Unit, datatype = string)

Each device can send data in real-time in form of key-value pairs.

Eg. - Vehicle could send the data like this:
Time: 6/4/2016 11:15:15.150, Latitude: 1.256, Longitude: -180.75, Speed: 50
Time: 6/4/2016 11:15:16.150, Latitude: 1.257, Longitude: -181.75, Speed: 51

Eg. - Temperature sensor could send data like this:
Time: 6/4/2016 - 11:15:15.150, Current Temperature: 100, Unit: Fahrenheit
Time: 6/4/2016 - 11:15:16.150, Current Temperature: 101, Unit: Fahrenheit

Now, because different devices can have different sets of attributes, I've been confused about how the data tables in Cassandra should be modeled. Some of the options I've considered so far are creating a table for each device or creating just a single table to store the values in Map data types. But, I'm still not sure as to which would the correct or better approach be to suit my needs. Please suggest some possible implementations. TIA

Dec 3, 2018 in IoT (Internet of Things) by Bharani
• 4,550 points
236 views

1 answer to this question.

0 votes

I think creating a single table that has a general purpose schema for collecting time-series data would be the best option in your case and should suit your needs perfectly.

CQL Sample:

CREATE TABLE timeline (
  device uuid,
  time timeuuid,
  key text,
  value blob,
  …
  PRIMARY KEY ((device, key), time)
);

Store values as blobs(custom serialization), map or numeric scalars, according to your application use case & data access patterns(like, how to read/write/delete and if updates are supported or not).

And, following are some useful materials related to Datastax posts on time-series modeling that should help you:

https://academy.datastax.com/resources/getting-started-time-series-data-modeling
http://www.datastax.com/dev/blog/advanced-time-series-data-modelling
http://www.datastax.com/dev/blog/advanced-time-series-with-cassandra

answered Dec 3, 2018 by nirvana
• 3,060 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

RPMs for IoT Agents of Backend Device Management GE in FIWARE IoT ecosystem

The RPMs for IDAS component are availaible. ...READ MORE

answered Jul 29, 2018 in IoT (Internet of Things) by DataKing99
• 8,100 points
36 views
0 votes
1 answer

Azure - What service to use for Arduino data (iot)

That's because the two services do completely ...READ MORE

answered Aug 1, 2018 in IoT (Internet of Things) by anonymous2
• 4,260 points
77 views
0 votes
1 answer

Application development in IoT

You can use AWS IoT with Amazon ...READ MORE

answered Aug 27, 2018 in IoT (Internet of Things) by anonymous2
• 4,260 points
26 views
0 votes
1 answer

Comparing technologies for Data Ingestion

All great questions. (Full disclosure I work ...READ MORE

answered Sep 25, 2018 in IoT (Internet of Things) by anonymous2
• 4,260 points
20 views
+1 vote
1 answer

Does learning IoT need you to buy a Raspberry Pi or similar IoT devices?

Though I'd recommend having the device for ...READ MORE

answered Oct 16, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
39 views
0 votes
1 answer

How to make existing devices IoT only?

IR Kit(opensource infrared remote controller) is a ...READ MORE

answered Feb 4 in IoT (Internet of Things) by Upasana
• 8,530 points
17 views
0 votes
1 answer

How to work a AWS IOT Lambda with a devices?

Hey KanaguRaj, use this for reference: https://serverless.com/b ...READ MORE

answered Apr 12 in IoT (Internet of Things) by Vardhan
• 12,200 points
43 views
0 votes
1 answer

Disk Management Commands in PowerShell for Windows IoT device

All libraries of the full .Net framework ...READ MORE

answered Nov 26, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
61 views
0 votes
1 answer

Display time in a Windows Core IoT app with a clock!

It is possible, but you should understand ...READ MORE

answered Jul 9, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
90 views