-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
31 lines (28 loc) · 1010 Bytes
/
schema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- Create schema
CREATE SCHEMA telemetry;
-- Create the devices table
CREATE TABLE telemetry.devices (
MacAddress VARCHAR(25) PRIMARY KEY NOT NULL,
PrivateIP VARCHAR(25) NOT NULL,
PublicIP VARCHAR(25) NOT NULL,
Hostname VARCHAR(25) NOT NULL,
OSType VARCHAR(25) NOT NULL
);
-- Create the rpi_temp_alert table
CREATE TABLE telemetry.rpi_temp_alert (
MacAddress VARCHAR(25) NOT NULL,
CPUuserLoad DOUBLE PRECISION NOT NULL,
MemoryUsage INT NOT NULL,
PrivateIP VARCHAR(25) NOT NULL,
Temperature REAL NOT NULL,
TotalProcesses INT NOT NULL,
TimeStamp TIMESTAMP WITH TIME ZONE NOT NULL,
CONSTRAINT fk_MacAddress FOREIGN KEY (MacAddress) REFERENCES telemetry.devices(MacAddress)
);
create table telemetry.metrics_new (
MacAddress VARCHAR(25) NOT NULL,
name varchar(50) not null,
value float8 not null ,
TimeStamp TIMESTAMP WITH TIME ZONE NOT NULL ,
CONSTRAINT fk_MacAddress FOREIGN KEY (MacAddress) REFERENCES telemetry.devices(MacAddress)
);