create database level_monitoring; -- create extension timescaledb; create table application_t ( id serial not null primary key, device_id VARCHAR(32) NOT NULL UNIQUE, label varchar(16) not null unique, sensor_type varchar(16) not null, ground_level numeric(10, 0) not null ); create table measurement_t ( time timestamptz not null, application_name text not null, raw_level numeric(10, 0), level numeric(10, 0), status text, battery float ); select create_hypertable('measurement_t', 'time'); insert into application_t (device_id, label, sensor_type, ground_level) values('eui-a84041a2c18341d6', 'deilbach', 'LDDS75', 300); -- create user preprocessor password 'geheim'; grant select on application_t to preprocessor; grant insert on measurement_t to preprocessor;