summaryrefslogtreecommitdiff
path: root/ebus-racket/doc/database-schema.sql
blob: 281659cb727688fc2f468fe6604d89f72a29c9b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE TABLE sensor (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        name TEXT,
        description TEXT
);
CREATE TABLE value (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        "timestamp" timestamp without time zone,
        sensor_id integer,
        type TEXT,
        value_float real,
        value_int integer,
        value_string TEXT,
        FOREIGN KEY(sensor_id) REFERENCES sensor(id)
);
CREATE INDEX sensor_idx_001 on sensor(id);
CREATE INDEX sensor_idx_002 on sensor(name);
CREATE INDEX value_idx_001 on value(sensor_id, timestamp);