-- phpMyAdmin SQL Dump
-- version 4.7.3
-- https://www.phpmyadmin.net/
--
-- Host: 767.m.tld.pl
-- Czas generowania: 28 Maj 2018, 09:58
-- Wersja serwera: 5.7.21-20-log
-- Wersja PHP: 5.6.30

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
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 */;

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

--
-- Struktura tabeli dla tabeli `boards`
--

CREATE TABLE `boards` (
  `board_id` char(36) NOT NULL,
  `presentation_id` char(36) NOT NULL,
  `date_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `type` varchar(100) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `preview` varchar(255) DEFAULT NULL,
  `image` varchar(50) DEFAULT NULL,
  `video` varchar(50) DEFAULT NULL,
  `config` text,
  `reactions` text,
  `order` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Struktura tabeli dla tabeli `boards_options`
--

CREATE TABLE `boards_options` (
  `option_id` char(36) NOT NULL,
  `board_id` char(36) NOT NULL,
  `text` varchar(150) NOT NULL,
  `correct` enum('0','1') NOT NULL DEFAULT '0',
  `image` varchar(50) DEFAULT NULL,
  `order` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Struktura tabeli dla tabeli `boards_reactions`
--

CREATE TABLE `boards_reactions` (
  `reaction_id` char(36) NOT NULL,
  `board_id` char(36) NOT NULL,
  `user_id` char(36) NOT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `reaction` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Struktura tabeli dla tabeli `presentations`
--

CREATE TABLE `presentations` (
  `presentation_id` char(36) NOT NULL,
  `user_id` char(36) NOT NULL,
  `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `accessKey` varchar(6) NOT NULL,
  `name` varchar(100) NOT NULL,
  `tempo` enum('1','2') NOT NULL DEFAULT '1',
  `results` enum('0','1') NOT NULL DEFAULT '0',
  `isOpen` enum('0','1') NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Struktura tabeli dla tabeli `results`
--

CREATE TABLE `results` (
  `result_id` char(36) NOT NULL,
  `presentation_id` char(36) NOT NULL,
  `board_id` char(36) NOT NULL,
  `option_id` char(36) DEFAULT NULL,
  `user_id` char(36) NOT NULL,
  `reply` text NOT NULL,
  `reply2` text,
  `time` int(11) NOT NULL,
  `points` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Struktura tabeli dla tabeli `results_users`
--

CREATE TABLE `results_users` (
  `user_id` char(36) NOT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

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

--
-- Struktura tabeli dla tabeli `users`
--

CREATE TABLE `users` (
  `user_id` char(36) NOT NULL,
  `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `role` enum('user','administrator') NOT NULL DEFAULT 'user',
  `password` varchar(255) NOT NULL,
  `active` enum('0','1') NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Zrzut danych tabeli `users`
--

INSERT INTO `users` (`user_id`, `date_created`, `date_updated`, `name`, `email`, `role`, `password`, `active`) VALUES
('9b9e6f81-c47d-11e7-a706-d43d7e4e79b6', '2017-11-08 12:09:02', '2017-11-08 12:09:02', 'Administrator', 'administrator@lmd.pl', 'administrator', '$2y$12$9xY9MMykiu1OoHnD5MrkP.xY4tJ9K4Y4KkSRFAzwT4rLGUSpqhYeq', '1'),
('e209f53a-e641-11e7-9c73-16d240896975', '2017-12-21 11:27:10', '2017-12-21 11:27:10', 'ZGD', 'zgd@lmd.pl', 'user', '$2y$12$9xY9MMykiu1OoHnD5MrkP.xY4tJ9K4Y4KkSRFAzwT4rLGUSpqhYeq', '1');

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

--
-- Struktura tabeli dla tabeli `users_reminder`
--

CREATE TABLE `users_reminder` (
  `reminder_id` char(36) NOT NULL,
  `user_id` char(36) NOT NULL,
  `date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `date_expired` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `token` varchar(32) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Indeksy dla zrzutów tabel
--

--
-- Indexes for table `boards`
--
ALTER TABLE `boards`
  ADD PRIMARY KEY (`board_id`),
  ADD KEY `presentation_id` (`presentation_id`);

--
-- Indexes for table `boards_options`
--
ALTER TABLE `boards_options`
  ADD PRIMARY KEY (`option_id`),
  ADD KEY `board_id` (`board_id`);

--
-- Indexes for table `presentations`
--
ALTER TABLE `presentations`
  ADD PRIMARY KEY (`presentation_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `results`
--
ALTER TABLE `results`
  ADD PRIMARY KEY (`result_id`),
  ADD KEY `presentation_id` (`presentation_id`),
  ADD KEY `board_id` (`board_id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `results_users`
--
ALTER TABLE `results_users`
  ADD PRIMARY KEY (`user_id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`user_id`);

--
-- Indexes for table `users_reminder`
--
ALTER TABLE `users_reminder`
  ADD PRIMARY KEY (`reminder_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `token` (`token`);

--
-- Ograniczenia dla zrzutów tabel
--

--
-- Ograniczenia dla tabeli `boards`
--
ALTER TABLE `boards`
  ADD CONSTRAINT `boards_ibfk_1` FOREIGN KEY (`presentation_id`) REFERENCES `presentations` (`presentation_id`) ON DELETE CASCADE;

--
-- Ograniczenia dla tabeli `boards_options`
--
ALTER TABLE `boards_options`
  ADD CONSTRAINT `boards_options_ibfk_1` FOREIGN KEY (`board_id`) REFERENCES `boards` (`board_id`) ON DELETE CASCADE;

--
-- Ograniczenia dla tabeli `presentations`
--
ALTER TABLE `presentations`
  ADD CONSTRAINT `presentations_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Ograniczenia dla tabeli `users_reminder`
--
ALTER TABLE `users_reminder`
  ADD CONSTRAINT `users_reminder_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

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