database
This commit is contained in:
41
src/udi/database/schema.sql
Normal file
41
src/udi/database/schema.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
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');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user