-- phpMyAdmin SQL Dump
-- version 4.2.12deb2+deb8u2
-- http://www.phpmyadmin.net
--
-- Hostiteľ: localhost
-- Čas generovania: St 07.Jún 2017, 13:11
-- Verzia serveru: 5.5.54-0+deb8u1
-- Verzia PHP: 5.6.30-0+deb8u1

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 utf8 */;

--
-- Databáza: `server`
--

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `devices`
--

CREATE TABLE IF NOT EXISTS `devices` (
`id` int(25) NOT NULL,
  `code` int(3) NOT NULL,
  `hash` varchar(255) NOT NULL,
  `type` char(1) NOT NULL,
  `active` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `events`
--

CREATE TABLE IF NOT EXISTS `events` (
`id` int(25) NOT NULL,
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `room` int(25) NOT NULL,
  `type` varchar(255) NOT NULL,
  `sensor` int(25) NOT NULL,
  `start` varchar(255) NOT NULL,
  `stop` varchar(255) NOT NULL,
  `timeout` int(25) NOT NULL,
  `days` varchar(255) NOT NULL,
  `event_on` int(25) NOT NULL,
  `output` int(255) NOT NULL,
  `value` int(25) NOT NULL,
  `active` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `outputs`
--

CREATE TABLE IF NOT EXISTS `outputs` (
`id` int(25) NOT NULL,
  `device` int(25) NOT NULL,
  `name` varchar(255) NOT NULL,
  `output_name` varchar(255) NOT NULL,
  `room` int(25) NOT NULL,
  `type` varchar(255) NOT NULL,
  `min_value` int(25) NOT NULL,
  `max_value` int(25) NOT NULL,
  `byte` int(25) NOT NULL,
  `length` int(25) NOT NULL,
  `value` int(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `rooms`
--

CREATE TABLE IF NOT EXISTS `rooms` (
`id` int(25) NOT NULL,
  `img` varchar(255) NOT NULL,
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `temp` int(25) NOT NULL,
  `termostat` int(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `sensors`
--

CREATE TABLE IF NOT EXISTS `sensors` (
`id` int(25) NOT NULL,
  `device` int(25) NOT NULL,
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `sensor_name` varchar(255) NOT NULL,
  `room` int(25) NOT NULL,
  `color` int(2) NOT NULL,
  `type` varchar(255) NOT NULL,
  `unit` varchar(255) NOT NULL,
  `value_type` varchar(255) NOT NULL,
  `byte` int(25) NOT NULL,
  `length` int(25) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `sensors_record`
--

CREATE TABLE IF NOT EXISTS `sensors_record` (
`id` int(25) NOT NULL,
  `sensor` int(25) NOT NULL,
  `value` double NOT NULL,
  `day` date NOT NULL,
  `hour` int(2) NOT NULL,
  `status` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `sensors_short_record`
--

CREATE TABLE IF NOT EXISTS `sensors_short_record` (
`id` int(25) NOT NULL,
  `sensor` int(25) NOT NULL,
  `value` int(25) NOT NULL,
  `time` int(25) NOT NULL,
  `status` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- --------------------------------------------------------

--
-- Štruktúra tabuľky pre tabuľku `termostats`
--

CREATE TABLE IF NOT EXISTS `termostats` (
`id` int(25) NOT NULL,
  `output` int(25) NOT NULL,
  `temp` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `devices`
--
ALTER TABLE `devices`
 ADD PRIMARY KEY (`id`);

--
-- Indexes for table `events`
--
ALTER TABLE `events`
 ADD UNIQUE KEY `id` (`id`);

--
-- Indexes for table `outputs`
--
ALTER TABLE `outputs`
 ADD PRIMARY KEY (`id`);

--
-- Indexes for table `rooms`
--
ALTER TABLE `rooms`
 ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sensors`
--
ALTER TABLE `sensors`
 ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sensors_record`
--
ALTER TABLE `sensors_record`
 ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sensors_short_record`
--
ALTER TABLE `sensors_short_record`
 ADD PRIMARY KEY (`id`);

--
-- Indexes for table `termostats`
--
ALTER TABLE `termostats`
 ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `devices`
--
ALTER TABLE `devices`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `events`
--
ALTER TABLE `events`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `outputs`
--
ALTER TABLE `outputs`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `rooms`
--
ALTER TABLE `rooms`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `sensors`
--
ALTER TABLE `sensors`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `sensors_record`
--
ALTER TABLE `sensors_record`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `sensors_short_record`
--
ALTER TABLE `sensors_short_record`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `termostats`
--
ALTER TABLE `termostats`
MODIFY `id` int(25) NOT NULL AUTO_INCREMENT;
/*!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 */;
