Templates/Operations & logistics
Sensor readings (Cassandra) database schema
Time series per device and day, newest first, with the latest reading kept in a table of its own.
3 tables, 0 references
Opens as a new diagram you can change. Free.
Tables
readings_by_device
One partition per device and day keeps partitions bounded.
- device_iduuid not null
- daydate not null
- recorded_attimestamp not null
- temperaturedouble
- humiditydouble
- batteryint
latest_reading_by_device
The last reading per device, overwritten on each write.
- device_iduuid not null
- recorded_attimestamp
- temperaturedouble
- humiditydouble
devices_by_site
Which devices a site has, for dashboards.
- site_iduuid not null
- device_iduuid not null
- nametext
- tagsset<text>
As CQL schema
The diagram also exports Sample rows (INSERT).
-- Sensor readings (Cassandra): Cassandra / ScyllaDB schema.
CREATE TABLE IF NOT EXISTS readings_by_device (
device_id uuid,
day date,
recorded_at timestamp,
temperature double,
humidity double,
battery int,
PRIMARY KEY ((device_id, day), recorded_at)
) WITH CLUSTERING ORDER BY (recorded_at DESC)
AND default_time_to_live = 7776000
AND comment = 'One partition per device and day keeps partitions bounded.';
CREATE TABLE IF NOT EXISTS latest_reading_by_device (
device_id uuid,
recorded_at timestamp,
temperature double,
humidity double,
PRIMARY KEY (device_id)
) WITH comment = 'The last reading per device, overwritten on each write.';
CREATE TABLE IF NOT EXISTS devices_by_site (
site_id uuid,
device_id uuid,
name text,
tags set<text>,
PRIMARY KEY (site_id, device_id)
) WITH CLUSTERING ORDER BY (device_id ASC)
AND comment = 'Which devices a site has, for dashboards.';
More Operations & logistics templates
- Fleet managementVehicles and drivers, trips, maintenance records and fuel logs.
- Shipping & trackingShipments of packages between addresses, carriers and tracking events.
- ManufacturingProducts with bills of materials, work orders routed through machine operations.
- Field serviceCustomer sites, jobs dispatched to technicians, visits and parts used.
- IT asset managementHardware and licences assigned to employees, with a maintenance history.
- IoT telemetryDevices with sensors streaming readings, thresholds and alerts.
- Ride hailingRiders request trips, drivers with vehicles accept, then payments and ratings.
- ParkingCar parks with spaces, permits for vehicles and paid parking sessions.
- Construction projectsProjects on sites, contractors, tasks, change orders and inspections.
- Farm managementFields planted with crops, harvests, equipment and livestock.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.