create type sensor_type as enum ( 'temperature', 'humidity', 'carbon_dioxide', 'pressure', 'proximity', 'light' ); create table sensors ( sensor_id varchar(255) primary key, sensor_type sensor_type not null, sampling_interval int not null default 3600, threshold_above float not null default 100, threshold_below float not null default 0, created_at timestamp not null default now(), updated_at timestamp not null default now() ); create index idx_sensors_sensor_id on sensors (sensor_id); create table registry ( sensor_id varchar(255) not null references sensors (sensor_id), value float not null, created_at timestamp not null default now() ) with ( timescaledb.hypertable, timescaledb.partition_column = 'created_at', timescaledb.segmentby = 'sensor_id' );