Data Modelling in cassandra for IOT

Sabarish Sathasivan

We are trying to use Apache Cassandra in an IoT based application. We are planning to create a device abstraction. Any user shall be able to define a device with a series of attributes. For each attribute, the user shall be able to define a series of properties like name , data type , minimum value , maximum value etc.

Some examples of devices are given below

Vehicle

The vehicle can have the following attributes

  1. Speed [name :- speed , data type:- double , minimum value :- 0 , maximum value :-300]
  2. Latitude [name :- speed , data :- double , minimum :- -90 , maximum :-90]
  3. Longitude[name :- Longitude, data :- double , minimum :- -180 , maximum :- 180]

Temperature Sensor

The temperature sensor can have the following attributes

  1. Current Temperature[name :- Current Temperation, data type:- double , minimum value :- 0 , maximum value :-300]
  2. Unit [name :- Unit , datatype:-string]

In real time , each device will be sending data as key value pairs .

For ex:- A Vehicle can send the following data

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

For ex:- A Temperature sensor can send the following data

Time :- 6/4/2016 11:15:15.150 , Current Temperature: 100, Unit : farenheit

Time :- 6/4/2016 11:15:16.150 , Latitude : 101 , Unit : farenheit

Since the attributes of different devices can be different , we are confused on how the model the tables in cassandra... Some of the options that came to mind are creating a table for a device, or create a single table and store the values in Map data types... We are little confused on which approach should be taken... Any suggestions is appreciated

Dario

I think the best option is to create only one table with a general purpose schema for collecting time-serie data.

Example CQL:

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

Values can be store as blob (custom serialization), map or numeric scalars, depending on your application use case & data access patterns (how to read/write/delete and if you plan to support to updates).

FYI useful related Datastax posts about time-series modeling:

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Data Vault Modelling

From Dev

Migrate data from cassandra to cassandra

From Dev

Standard for modelling JSON data in IOS

From Dev

Creating an expandable grid in MVC3 - data modelling

From Dev

Modelling data for a water metering application

From Dev

modelling hierarchical data warehouse dimension

From Dev

data auditing in Cassandra

From Dev

Cassandra and unstructured data

From Dev

Cassandra Data Modelling and designing the Clustering

From Dev

Cassandra- Data modelling for UserProfilie

From Dev

Cassandra modelling, I have a billion of some kind of digital code to store, should I use wide row (CQL with cluster key)?

From Dev

Cassandra data modelling less then 1000 records to fit in one row

From Dev

Data modeling with Cassandra

From Dev

Modelling Cassandra Many-to-Many Relation for Sensor Data

From Dev

Modelling of hierarchical entities in Cassandra

From Dev

Cassandra Data Modelling: Use a Map or have a lot of empty columns?

From Dev

UML for system modelling or for software modelling?

From Dev

Price data modelling

From Dev

Data modelling in MongoDB

From Dev

Creating an expandable grid in MVC3 - data modelling

From Dev

Suggestions for data modelling in Neo4j

From Dev

modelling hierarchical data warehouse dimension

From Dev

Cassandra Time-Series data modelling

From Dev

Cassandra modelling, I have a billion of some kind of digital code to store, should I use wide row (CQL with cluster key)?

From Dev

Cassandra data modelling less then 1000 records to fit in one row

From Dev

Data Modelling in cassandra for IOT

From Dev

Core Data Modelling from SQL

From Dev

Azure IoT Hub Metrics Data

From Dev

GraphQL data modelling - extended types (Prisma)

Related Related

HotTag

Archive