Common Models

May 27, 2024

IoTDB

Predictive maintenance is a game-changer for asset-intensive industries, leveraging data to forecast equipment failures before they happen. Snowflake, with its powerful data warehousing and analytics capabilities, is an ideal platform for building and deploying predictive maintenance solutions. In this section, we'll guide you through creating a non-synthetic and statistically appropriate sample IoT data model in Snowflake, setting the stage for future predictive maintenance demos.

Understanding the Importance of Predictive Maintenance

Traditional maintenance strategies often rely on reactive repairs or scheduled maintenance, which can be inefficient and costly. Predictive maintenance, on the other hand, utilizes sensor data and advanced analytics to predict equipment failures, allowing for proactive interventions that can save money, reduce downtime, and extend asset lifespans.

The IoT Data Model

The core of any predictive maintenance solution is a well-structured data model that captures relevant information from IoT sensors. 


DemoHub - IoTDB Data Model - Version 1.2.7 (updated 05/28/2024)

Here's the script to create the database, file format, stage, and load data into your IoT table. The table schema and column descriptions are also provided. 

>_ SQL

/*
------------------------------------------------------------------------------
-- Snowflake Demo Script: IoT Data Model 
-- 
-- Description: 
-- This script sets up an IoT data model in Snowflake, loads data from an
-- external stage, and prepares the environment for future predictive 
-- maintenance demos.
--
-- Author: Fru N.
-- Website: DemoHub.dev
--
-- Date: May 27, 2024
--
-- Copyright (c) 2024 DemoHub.dev. All rights reserved. 
--
-- Disclaimer:  
-- This script is for educational and demonstration purposes only. It is not
-- affiliated with or endorsed by Snowflake Computing. Use this code at your 
-- own risk.
------------------------------------------------------------------------------
*/


>_ SQL

-- +----------------------------------------------------+
-- |             1. DATABASE AND SCHEMA SETUP          |
-- +----------------------------------------------------+

-- Create or replace the database
CREATE OR REPLACE DATABASE IoTDB;

-- Use the database
USE IoTDB;

-- Create a schema
CREATE OR REPLACE SCHEMA


>_ SQL

-- +----------------------------------------------------+
-- |            2. CREATE FILE FORMAT                 |
-- +----------------------------------------------------+

-- Create a file format to specify CSV structure
CREATE OR REPLACE FILE FORMAT CSV_SCHEMA
    TYPE = CSV
    PARSE_HEADER = TRUE
    SKIP_BLANK_LINES = TRUE
    TRIM_SPACE = TRUE
    ERROR_ON_COLUMN_COUNT_MISMATCH = FALSE


>_ SQL

-- +----------------------------------------------------+
-- |              3. CREATE STAGE                      |
-- +----------------------------------------------------+

-- Create a stage to reference external data
CREATE OR REPLACE STAGE DEMOHUB_S3_INT 
    URL = 's3://demohubpublic/data/'
    DIRECTORY = ( ENABLE = true )
    COMMENT = 'DemoHub S3 datasets'


>_ SQL

-- +----------------------------------------------------+
-- |        4. LOAD DATA USING SCHEMA INFERENCE        |
-- +----------------------------------------------------+
-- Create and populate the table using schema inference
CREATE OR REPLACE TABLE iot.sensor_data USING TEMPLATE (
SELECT ARRAY_AGG(OBJECT_CONSTRUCT(*))
    FROM TABLE (INFER_SCHEMA(
    LOCATION=>'@demohub_s3_int/iot/sensor_data/',
    FILE_FORMAT=>'CSV_SCHEMA')))


>_ SQL

-- +----------------------------------------------------+
-- |                5. COPY DATA INTO TABLE             |
-- +----------------------------------------------------+
-- Load the actual data from the stage into the table
COPY INTO iot.sensor_data FROM '@demohub_s3_int/iot/sensor_data/'
FILE_FORMAT = 'CSV_SCHEMA'


>_ SQL

-- +----------------------------------------------------+
-- |                6. ADD COLUMN COMMENTS & DESCRIPTIONS             |
-- +----------------------------------------------------+
ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN unit_number IS 'Unique identifier for the equipment unit';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN time_in_cycles IS 'Operating time of the unit in cycles';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN setting_1 IS 'Operating setting 1 (e.g., temperature)';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN setting_2 IS 'Operating setting 2 (e.g., pressure)';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN TRA IS 'Sensor reading: Total runs to alarm';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN T2 IS 'Sensor reading: Temperature at sensor 2';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN T24 IS 'Sensor reading: Temperature at sensor 24';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN T30 IS 'Sensor reading: Temperature at sensor 30';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN T50 IS 'Sensor reading: Temperature at sensor 50';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN P2 IS 'Sensor reading: Pressure at sensor 2';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN P15 IS 'Sensor reading: Pressure at sensor 15';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN P30 IS 'Sensor reading: Pressure at sensor 30';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN Nf IS 'Sensor reading: Fan speed';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN Nc IS 'Sensor reading: Core speed';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN epr IS 'Sensor reading: Engine pressure ratio';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN Ps30 IS 'Sensor reading: Static pressure at stage 30';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN phi IS 'Sensor reading: Physical fan speed';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN NRf IS 'Sensor reading: Fan efficiency';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN NRc IS 'Sensor reading: Core efficiency';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN BPR IS 'Sensor reading: Bypass ratio';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN farB IS 'Sensor reading: Burner fuel-air ratio';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN htBleed IS 'Sensor reading: High-pressure turbine bleed';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN Nf_dmd IS 'Sensor reading: Demanded fan speed';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN PCNfR_dmd IS 'Sensor reading: Demanded corrected fan speed';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN W31 IS 'Sensor reading: HPT coolant bleed';

ALTER TABLE iot.sensor_data 
    MODIFY COMMENT ON COLUMN W32 IS 'Sensor reading: LPT coolant bleed'

Table Explanation:

  • Each row in this table represents a set of sensor readings taken at a particular time for a specific equipment unit.

  • The unit_number column uniquely identifies each piece of equipment.

  • time_in_cycles tracks the operating time of the equipment, providing context for wear and tear.

  • The remaining columns capture various sensor readings (temperature, pressure, speed, etc.) relevant to the equipment's health and performance.

  • All sensor values are stored as DOUBLE PRECISION.

Key Points: This data model provides an excellent starting point for several types of analysis:

  • Trend Analysis: Identify patterns and trends in sensor data over time to detect anomalies or predict potential failures.

  • Feature Engineering: Create new features based on combinations of sensor readings or calculations to capture more complex relationships in the data.

  • Machine Learning: Train predictive models to forecast equipment failures or estimate remaining useful life.

  • Root Cause Analysis: When a failure occurs, investigate historical sensor data to understand the contributing factors.

Conclusion:

With this well-structured IoT data model in place, you are now ready to explore the capabilities of Snowflake for predictive maintenance. In the upcoming demo’s, we'll delve into using advanced analytics and machine learning techniques to build models that can proactively identify potential equipment failures and optimize maintenance schedules.

Join Our Community

Join our newsletter list for occasional updates, products and insights.

Join Our Community

Join our newsletter list for occasional updates, products and insights.

Join Our Community

Join our newsletter list for occasional updates, products and insights.

More from
Common Models

SalesDB

SalesDB

SalesDB

CaresDB

CaresDB

CaresDB

OrdersDB

OrdersDB

OrdersDB

MediSnowDB

MediSnowDB

MediSnowDB

Copyright 2020-24 - All Right Reserved

Copyright 2020-24 - All Right Reserved

Copyright 2020-24 - All Right Reserved