create extension if not exists timescaledb; create table application_t ( id serial not null primary key, label text not null unique, attributes jsonb ); create table sensor_type_t ( id serial not null primary key, label text not null unique, variable text not null, unit text not null, converter text not null, attributes jsonb ); create table sensor_t ( id serial not null primary key, label text not null, application int references application_t(id), sensor_type int references sensor_type_t(id), attributes jsonb, unique (label, application) ); create table measurement_t ( time timestamp without time zone not null, application text not null, sensor_type text not null, sensor text not null, variable text not null, unit text not null, value double precision not null, attributes jsonb ); select create_hypertable('measurement_t', 'time');