Format sql

This commit is contained in:
WQY\qiong
2022-10-09 11:06:19 +08:00
parent d99c0eacbf
commit 9accb467b2
58 changed files with 283 additions and 283 deletions

View File

@@ -1,30 +1,30 @@
-- [CONTROLS]
CREATE TYPE CONTROLS_1_PREP AS ENUM ('ABOVE', 'BELOW');
create type controls_1_prep as enum ('above', 'below');
-- LINK linkID status IF NODE nodeID ABOVE / BELOW value
CREATE TABLE CONTROLS_1
create table controls_1
(
LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting
, NodeID VARCHAR(32) REFERENCES _NODE(ID) NOT NULL
, Prep CONTROLS_1_PREP NOT NULL
, Value NUMERIC NOT NULL
linkid varchar(32) primary key references _link(id)
, status text not null -- open / closed, a pump speed setting, or a control valve setting
, nodeid varchar(32) references _node(id) not null
, prep controls_1_prep not null
, value numeric not null
);
-- LINK linkID status AT TIME time
CREATE TABLE CONTROLS_2
create table controls_2
(
LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting
, Time INTERVAL HOUR
linkid varchar(32) primary key references _link(id)
, status text not null -- open / closed, a pump speed setting, or a control valve setting
, time interval hour
);
-- LINK linkID status AT CLOCKTIME clocktime AM / PM
CREATE TABLE CONTROLS_3
create table controls_3
(
LinkID VARCHAR(32) PRIMARY KEY REFERENCES _LINK(ID)
, Status TEXT NOT NULL -- OPEN / CLOSED, a pump speed setting, or a control valve setting
, Clock_Time_Hour INTERVAL HOUR -- get AM/PM from it
, Clock_Time_Min INTERVAL MINUTE
linkid varchar(32) primary key references _link(id)
, status text not null -- open / closed, a pump speed setting, or a control valve setting
, clock_time_hour interval hour -- get am/pm from it
, clock_time_min interval minute
);