create table sensor
(
    sid serial not null constraint sensor_pk primary key,
    id integer not null,
    model varchar(128) not null,
    channel integer not null,
    ignored boolean default false not null
);

create unique index sensor_id_model_channel_uindex on sensor (id, model, channel);

create table reading
(
    sid integer not null constraint reading_sensor_sid_fk references sensor on update cascade on delete cascade,
    time timestamp not null,
    temperature numeric(5,2),
    humidity numeric(5,2),
    moisture numeric(5,2)
);