|Cloud data management model|
Here comes the catch: Even if IOTF provides data storage, it should not considered as primary storage of your device data in production use. There are two main reasons:
- Storing excess amount of data in IOTF is expensive
- IOTF database does not provide QoS, data may be lost if delivered at high rate
Majority of device data generated in the world is deprecated just few seconds after it's created. Data aggregation may significantly reduce the amount of data that really needs to be stored for later use. However, if you wish to store all raw device data for later use like analytics not invented yet, it's better to use some long term data storage solution like Object storage, as data over there costs only a fraction of what it would cost to store it in the active No-SQL database.
This creates a three-tier data management model where Watson IOT Platform (IOTF) is the front-line to receive the data from devices. No-SQL database is the place where active application data is processed, and finally a Object storage or similar place is the attic for historical data perhaps never needed, but nobody dares to throw away.
Bluemix and Watson IoT Platform are tightly integrated and it's very easy to access the data in Bluemix application. Here is an example of simplest possible glue-logic to integrate IOTF and No-SQL database with each other ,Cloudant in this case. The example is implemented with Node-RED running in Bluemix Node.js application.
|Integration of IOTF and Cloudant with Node-RED app in Bluemix.|
In addition to being more robust than using IOTF database, this may be more economic as well. Free plan of IOTF provides storage space of 1GB for device data, where as Cloudant offers 20GB free quota per instance. Fetching data from Non-SQL database is also more comfortable with efficient query algorithms. Actually the REST API of IOTF only provides max 200 items at a time.
Reading data from Cloudant is as simple as writing it in, in Node-RED application. Here is an example of simplest possible implementation of REST API to fetch data from the database.
|Implementation of REST API to fetch data from Cloudant in Node-RED.|