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 4, 2018 in IoT (Internet of Things) by Bharani
• 4,660 points
1,734 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).

answered Dec 4, 2018 by nirvana
• 3,130 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 30, 2018 in IoT (Internet of Things) by DataKing99
• 8,250 points
827 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,240 points
1,068 views
0 votes
1 answer
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,240 points
669 views
0 votes
1 answer

Comparing technologies for Data Ingestion

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

answered Sep 26, 2018 in IoT (Internet of Things) by anonymous2
• 4,240 points
601 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,130 points
1,045 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, 2019 in IoT (Internet of Things) by Upasana
• 8,620 points
753 views
0 votes
1 answer

How to work a AWS IOT Lambda with a devices?

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

answered Apr 12, 2019 in IoT (Internet of Things) by Vardhan
• 13,150 points
787 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,130 points
1,111 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 10, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,563 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP