-
Notifications
You must be signed in to change notification settings - Fork 2
/
database.sql
131 lines (111 loc) · 3.35 KB
/
database.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 26. Aug 2020 um 09:37
-- Server-Version: 10.1.45-MariaDB-1~xenial
-- PHP-Version: 7.0.33-0ubuntu0.16.04.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Datenbank: `envsensors`
--
DELIMITER $$
--
-- Funktionen
--
CREATE DEFINER=`envsensors`@`localhost` FUNCTION `get_absolutefeuchte` (`temp` DECIMAL(10,3), `hum` DECIMAL(10,3)) RETURNS DOUBLE begin
declare sdd double default 0;
declare dd double default 0;
declare td double default 0;
declare tk double default 0;
declare af double default 0;
declare v double default 0;
declare a double default 7.5;
declare b double default 237.3;
set sdd = 6.1078 * power(10, ((a*temp)/(b+temp)));
set dd = hum/100 * sdd;
set v = LOG(10, dd/6.1078);
set td = b*v/(a-v);
set tk = temp + 273.15;
set af = power(10, 5) * 18.016 / 8314.3 * dd/tk;
return af;
end$$
CREATE DEFINER=`envsensors`@`localhost` FUNCTION `get_taupunkt` (`temp` DECIMAL(10,3), `hum` DECIMAL(10,3)) RETURNS DOUBLE begin
declare sdd double default 0;
declare dd double default 0;
declare td double default 0;
declare v double default 0;
declare a double default 7.5;
declare b double default 237.3;
set sdd = 6.1078 * power(10, ((a*temp)/(b+temp)));
set dd = hum/100 * sdd;
set v = LOG(10, dd/6.1078);
set td = b*v/(a-v);
return td;
end$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sensors`
--
CREATE TABLE `sensors` (
`id` int(11) NOT NULL,
`name` varchar(32) NOT NULL,
`description` text NOT NULL,
`monitoring` tinyint(4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `sensorvalues`
--
CREATE TABLE `sensorvalues` (
`id` bigint(20) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`sensorid` int(11) NOT NULL,
`temp` decimal(10,3) NOT NULL,
`press` decimal(10,3) NOT NULL,
`hum` decimal(10,3) NOT NULL,
`power` decimal(10,3) NOT NULL,
`kwh_since_start` decimal(15,5) NOT NULL,
`kwh_since_last_send` decimal(10,5) NOT NULL,
`exceptiondata` text NOT NULL,
`persons` int(11) NOT NULL,
`co2` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Indizes der exportierten Tabellen
--
--
-- Indizes für die Tabelle `sensors`
--
ALTER TABLE `sensors`
ADD PRIMARY KEY (`id`);
--
-- Indizes für die Tabelle `sensorvalues`
--
ALTER TABLE `sensorvalues`
ADD PRIMARY KEY (`id`),
ADD KEY `timestampindex` (`timestamp`),
ADD KEY `sensorindex` (`sensorid`);
--
-- AUTO_INCREMENT für exportierte Tabellen
--
--
-- AUTO_INCREMENT für Tabelle `sensors`
--
ALTER TABLE `sensors`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT für Tabelle `sensorvalues`
--
ALTER TABLE `sensorvalues`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4525167;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;