IoT Device Telemetry ER diagram and database schema
The IoT Device Telemetry database schema is a DB Planner template with 25 tables, 216 columns and 51 relationships, free to use. Core tables include alert_events, alert_rule_targets, alert_rules, alerts. It can be opened as an interactive ER diagram or exported as PostgreSQL, MySQL, or SQL Server DDL.
- Tables
- 25
- Columns
- 216
- Relationships
- 51
- Category
- IoT
- Exports
- DBML, SQL, C#
- Price
- Free
What this schema models
A complete IoT device telemetry database design, built for fleets that report millions of readings a day: 25 tables, 20 enums and 51 relationships covering tenants, sites and users, device models, devices, gateways and rotating credentials, device groups, per-device sensor channels, raw telemetry and hourly rollups, connection events and heartbeats, cloud-to-device commands, alert rules, alerts and their timelines, and firmware releases with staged rollouts. THE FOUR DESIGN RULES 1. Telemetry is narrow and append-only. One row per channel per instant (channel, time, value, quality), keyed on (channel_id, recorded_at) with no surrogate id. The table is partitioned by time with a BRIN index on recorded_at, retention is DROP PARTITION, and a gateway replaying its offline buffer is deduplicated by the key. 2. Charts read rollups, never raw rows. telemetry_hourly stores count, min, max, sum, first and last per channel per hour. Sums and counts (not averages) roll up to days exactly, and a late reading recomputes only the hour it belongs to. 3. Commands are a state machine with an expiry. Queued, sent, delivered, acknowledged, or failed, or expired, each with its own timestamp, plus a message id echoed back so a duplicate ack is recognised. A reboot queued for an offline device never fires three days later. 4. Reported is not desired. devices.current_firmware_id is what the device says it runs; a rollout is the intent, with canary stages, a soak time, an automatic pause past a failure threshold, and per-device status that counts as success only when the device reports the new version. DETAILS WORTH STEALING - A gateway is a device (with a one-to-one gateways subtype), so credentials, heartbeats, commands and firmware rollouts apply to gateways unchanged. - Channels are templated per device model and instantiated per device, with per-sensor calibration offset and scale applied at ingest. - Credential rotation overlaps: the new certificate is issued and seen in use before the old one is revoked, and only fingerprints and public certificates are stored. - Alert rules have hysteresis (a separate clear threshold) and a hold time, and a partial unique index allows one live alert per rule per sensor, so a flapping sensor never opens hundreds. - Offline detection is a no-data rule measured in missed heartbeat intervals for the device model, not one fixed timeout. - Escalation is just a second notification target with a delay. WHAT YOU GET Clean DBML that imports directly into DB Planner, and a laid-out board with zones color-coded and framed: tenants and sites, firmware, device fleet, channels and telemetry, connectivity and commands, and alerting. Every table carries a note. Written for Postgres: device labels, command payloads and results, alert details and rollout maintenance windows are jsonb (JSON in MySQL, NVARCHAR(MAX) in SQL Server), and the time-partitioning advice for readings uses Postgres features, so plan the equivalent on other engines. Useful for developers building an IoT platform or fleet monitoring product, and for students who need a realistic IoT ER diagram for a DBMS project. This is a schema design reference; at very high ingest rates raw readings often move to a dedicated time-series database while the rest stays relational.
Tables (25)
| Table | Columns |
|---|---|
| alert_events | 8 |
| alert_rule_targets | 3 |
| alert_rules | 14 |
| alerts | 15 |
| channels | 8 |
| connection_events | 9 |
| device_commands | 17 |
| device_credentials | 11 |
| device_group_members | 3 |
| device_groups | 4 |
| device_heartbeats | 7 |
| device_models | 8 |
| devices | 13 |
| firmware_releases | 13 |
| firmware_rollouts | 12 |
| gateways | 5 |
| model_channels | 9 |
| notification_targets | 6 |
| rollout_devices | 9 |
| rollout_stages | 7 |
| sites | 7 |
| telemetry_hourly | 9 |
| telemetry_readings | 5 |
| tenants | 7 |
| users | 7 |
Relationships (51)
alert_events.alert_id references alerts.idmany to onealert_events.notification_target_id references notification_targets.idmany to onealert_events.user_id references users.idmany to onealert_rule_targets.alert_rule_id references alert_rules.idmany to onealert_rule_targets.notification_target_id references notification_targets.idmany to onealert_rules.created_by references users.idmany to onealert_rules.device_group_id references device_groups.idmany to onealert_rules.model_channel_id references model_channels.idmany to onealert_rules.tenant_id references tenants.idmany to onealerts.acknowledged_by references users.idmany to onealerts.alert_rule_id references alert_rules.idmany to onealerts.channel_id references channels.idmany to onealerts.device_id references devices.idmany to onealerts.resolved_by references users.idmany to onechannels.device_id references devices.idmany to onechannels.model_channel_id references model_channels.idmany to oneconnection_events.credential_id references device_credentials.idmany to oneconnection_events.device_id references devices.idmany to oneconnection_events.via_gateway_id references gateways.device_idmany to onedevice_commands.alert_id references alerts.idmany to onedevice_commands.device_id references devices.idmany to onedevice_commands.issued_by references users.idmany to onedevice_credentials.device_id references devices.idmany to onedevice_credentials.replaces_credential_id references device_credentials.idmany to onedevice_group_members.device_group_id references device_groups.idmany to onedevice_group_members.device_id references devices.idmany to onedevice_groups.tenant_id references tenants.idmany to onedevice_heartbeats.device_id references devices.idmany to onedevices.current_firmware_id references firmware_releases.idmany to onedevices.device_model_id references device_models.idmany to onedevices.gateway_device_id references gateways.device_idmany to onedevices.id references gateways.device_idone to onedevices.site_id references sites.idmany to onedevices.tenant_id references tenants.idmany to onefirmware_releases.device_model_id references device_models.idmany to onefirmware_rollouts.created_by references users.idmany to onefirmware_rollouts.device_group_id references device_groups.idmany to onefirmware_rollouts.firmware_release_id references firmware_releases.idmany to onefirmware_rollouts.tenant_id references tenants.idmany to onemodel_channels.device_model_id references device_models.idmany to onenotification_targets.tenant_id references tenants.idmany to onenotification_targets.user_id references users.idmany to onerollout_devices.device_id references devices.idmany to onerollout_devices.from_firmware_id references firmware_releases.idmany to onerollout_devices.rollout_id references firmware_rollouts.idmany to onerollout_devices.rollout_stage_id references rollout_stages.idmany to onerollout_stages.rollout_id references firmware_rollouts.idmany to onesites.tenant_id references tenants.idmany to onetelemetry_hourly.channel_id references channels.idmany to onetelemetry_readings.channel_id references channels.idmany to oneusers.tenant_id references tenants.idmany to one
How to use this template
- Open the ER diagram to see the tables and how they relate.
- Copy it into your workspace. You get your own editable copy, in DBML.
- Export it as PostgreSQL, MySQL, or SQL Server DDL, or as C# models.
The copy opens in DB Planner’s ER diagram tool, with the schema as text in the DBML editor beside it. Have a database already? Turn its SQL into an ER diagram instead.
Frequently asked questions
- What is in the IoT Device Telemetry database schema?
- 25 tables and 51 relationships, across 216 columns. The table names and the full relationship list are shown on this page.
- Can I export it to PostgreSQL or MySQL?
- Yes. Every DB Planner template exports as DBML, as PostgreSQL, MySQL, or SQL Server DDL, and as C# models.
- Is this template free?
- Yes. You can open it in the browser without an account, and copy it into your own workspace with a free DB Planner account.
- Can I change it after copying it?
- Yes. A copy is yours: you can rename tables, add columns, and export it. Changes the author makes later do not affect your copy.