34 lines
982 B
MySQL
34 lines
982 B
MySQL
|
CREATE DATABASE IF NOT EXISTS `openager` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||
|
USE `openager`;
|
||
|
|
||
|
-- --------------------------------------------------------
|
||
|
|
||
|
--
|
||
|
-- Tabellenstruktur für Tabelle `sensor_aggr`
|
||
|
--
|
||
|
|
||
|
CREATE TABLE IF NOT EXISTS `sensor_aggr` (
|
||
|
`epoch` bigint(20) NOT NULL,
|
||
|
`device` varchar(255) NOT NULL,
|
||
|
`sensor` varchar(255) NOT NULL,
|
||
|
`value` double NOT NULL,
|
||
|
PRIMARY KEY (`epoch`,`device`,`sensor`)
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||
|
|
||
|
-- --------------------------------------------------------
|
||
|
|
||
|
--
|
||
|
-- Tabellenstruktur für Tabelle `sensor_data`
|
||
|
--
|
||
|
|
||
|
CREATE TABLE IF NOT EXISTS `sensor_data` (
|
||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||
|
`device` text NOT NULL,
|
||
|
`sensor` text NOT NULL,
|
||
|
`value` double NOT NULL,
|
||
|
`epoch` bigint(20) NOT NULL,
|
||
|
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
|
||
|
PRIMARY KEY (`id`),
|
||
|
KEY `sensor_data_idx1` (`timestamp`),
|
||
|
KEY `sensor_data_idx2` (`epoch`)
|
||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|