-- Adminer 4.8.1 MySQL 5.7.27-0ubuntu0.16.04.1 dump

SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

CREATE TABLE `anketa_hlasy` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `anketa_id` int(11) NOT NULL,
  `moznost_id` int(11) NOT NULL,
  `uzivatel_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `anketa_id` (`anketa_id`),
  KEY `moznost_id` (`moznost_id`),
  KEY `uzivatel_id` (`uzivatel_id`),
  CONSTRAINT `anketa_hlasy_ibfk_1` FOREIGN KEY (`anketa_id`) REFERENCES `ankety` (`id`) ON DELETE CASCADE,
  CONSTRAINT `anketa_hlasy_ibfk_2` FOREIGN KEY (`moznost_id`) REFERENCES `anketa_moznosti` (`id`) ON DELETE CASCADE,
  CONSTRAINT `anketa_hlasy_ibfk_3` FOREIGN KEY (`uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `anketa_moznosti` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `anketa_id` int(11) NOT NULL,
  `text_moznost` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `anketa_id` (`anketa_id`),
  CONSTRAINT `anketa_moznosti_ibfk_1` FOREIGN KEY (`anketa_id`) REFERENCES `ankety` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `ankety` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tym_id` int(11) NOT NULL,
  `nazev` varchar(200) COLLATE utf8_czech_ci NOT NULL,
  `popis` text COLLATE utf8_czech_ci,
  `vytvoril_uzivatel_id` int(11) NOT NULL,
  `datum_vytvoreni` datetime DEFAULT CURRENT_TIMESTAMP,
  `aktivni` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `tym_id` (`tym_id`),
  KEY `vytvoril_uzivatel_id` (`vytvoril_uzivatel_id`),
  CONSTRAINT `ankety_ibfk_1` FOREIGN KEY (`tym_id`) REFERENCES `tymy` (`id`) ON DELETE CASCADE,
  CONSTRAINT `ankety_ibfk_2` FOREIGN KEY (`vytvoril_uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `clenove_tymu` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tym_id` int(11) NOT NULL,
  `uzivatel_id` int(11) NOT NULL,
  `role_v_tymu` enum('trener','asistent','hrac') COLLATE utf8_czech_ci DEFAULT 'hrac',
  PRIMARY KEY (`id`),
  KEY `tym_id` (`tym_id`),
  KEY `uzivatel_id` (`uzivatel_id`),
  CONSTRAINT `clenove_tymu_ibfk_1` FOREIGN KEY (`tym_id`) REFERENCES `tymy` (`id`) ON DELETE CASCADE,
  CONSTRAINT `clenove_tymu_ibfk_2` FOREIGN KEY (`uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `dochazka` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `udalost_id` int(11) NOT NULL,
  `uzivatel_id` int(11) NOT NULL,
  `stav` enum('pritomen','nepritomen','omluven','pozdni_prichod','nevyjadril_se') COLLATE utf8_czech_ci DEFAULT 'nevyjadril_se',
  `poznamka` text COLLATE utf8_czech_ci,
  PRIMARY KEY (`id`),
  KEY `udalost_id` (`udalost_id`),
  KEY `uzivatel_id` (`uzivatel_id`),
  CONSTRAINT `dochazka_ibfk_1` FOREIGN KEY (`udalost_id`) REFERENCES `udalosti` (`id`) ON DELETE CASCADE,
  CONSTRAINT `dochazka_ibfk_2` FOREIGN KEY (`uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `poznamky` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tym_id` int(11) NOT NULL,
  `uzivatel_id` int(11) NOT NULL,
  `obsah` text COLLATE utf8_czech_ci NOT NULL,
  `datum` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `tym_id` (`tym_id`),
  KEY `uzivatel_id` (`uzivatel_id`),
  CONSTRAINT `poznamky_ibfk_1` FOREIGN KEY (`tym_id`) REFERENCES `tymy` (`id`) ON DELETE CASCADE,
  CONSTRAINT `poznamky_ibfk_2` FOREIGN KEY (`uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `statistiky_hodnoty` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `udalost_id` int(11) NOT NULL,
  `uzivatel_id` int(11) NOT NULL,
  `stat_typ_id` int(11) NOT NULL,
  `hodnota` int(11) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `udalost_id` (`udalost_id`),
  KEY `uzivatel_id` (`uzivatel_id`),
  KEY `stat_typ_id` (`stat_typ_id`),
  CONSTRAINT `statistiky_hodnoty_ibfk_1` FOREIGN KEY (`udalost_id`) REFERENCES `udalosti` (`id`) ON DELETE CASCADE,
  CONSTRAINT `statistiky_hodnoty_ibfk_2` FOREIGN KEY (`uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE,
  CONSTRAINT `statistiky_hodnoty_ibfk_3` FOREIGN KEY (`stat_typ_id`) REFERENCES `statistiky_typy` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `statistiky_typy` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `sport` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `nazev` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `tymy` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nazev` varchar(150) COLLATE utf8_czech_ci NOT NULL,
  `popis` text COLLATE utf8_czech_ci,
  `vytvoreno` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `udalosti` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tym_id` int(11) NOT NULL,
  `typ` enum('trenink','zapas') COLLATE utf8_czech_ci NOT NULL,
  `misto` varchar(200) COLLATE utf8_czech_ci DEFAULT NULL,
  `datum` datetime NOT NULL,
  `popis` text COLLATE utf8_czech_ci,
  PRIMARY KEY (`id`),
  KEY `tym_id` (`tym_id`),
  CONSTRAINT `udalosti_ibfk_1` FOREIGN KEY (`tym_id`) REFERENCES `tymy` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


CREATE TABLE `uzivatele` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uzivatelske_jmeno` varchar(150) COLLATE utf8_czech_ci NOT NULL,
  `jmeno` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `prijmeni` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `heslo` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `role` enum('admin','trener','sportovec') COLLATE utf8_czech_ci DEFAULT 'sportovec',
  `datum_registrace` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`uzivatelske_jmeno`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

INSERT INTO `uzivatele` (`id`, `uzivatelske_jmeno`, `jmeno`, `prijmeni`, `heslo`, `role`, `datum_registrace`) VALUES
(1,	'admin',	'Admin',	'Systémový',	'$2a$12$jvMdH6tUBEOi.Ob.uYmeSOe4qZjRmlul7i3lg.11hpasL6GpAFEUu',	'admin',	'2025-12-17 17:20:25'),
(2,	'jannovak',	'Jan',	'Novák',	'$2a$12$oxtzuqv2Df6YfKu5Cbc.xuzZ7n79R2lg9IpskQ6ScE35v18T7FPYC',	'trener',	'2025-12-17 17:20:25'),
(3,	'petrsvoboda',	'Petr',	'Svoboda',	'$2a$12$V8D8hkn2A.bEH5ttx3mZpOGystDIpqdRkjDBErawj1UNVVkx/mfh2',	'trener',	'2025-12-17 17:20:25'),
(4,	'tomasmaly',	'Tomáš',	'Malý',	'$2a$12$o4onw.jmd1RtJ5MxOY8pZODcCCIVM3qznAcTbDGbe/VGurSoCxtaC',	'sportovec',	'2025-12-17 17:20:25'),
(5,	'lukaskral',	'Lukáš',	'Král',	'$2a$12$gutI2va2McoOsOxXjhopZe1kWghTDXhaFSGF.hmGRnfL/QrXVFqHa',	'sportovec',	'2025-12-17 17:20:25'),
(6,	'davidcerny',	'David',	'Černý',	'$2a$12$Bfn/fT/214af1U0aI3gIY.seL1K7HtaiNKWz4YQnQDK92z12JIzKe',	'sportovec',	'2025-12-17 17:20:25'),
(8,	'havlan',	'havlan',	'havlan',	'$2y$10$lGASb7nsHlY4tbZG7axCrut248raUE//UP9MWoonVTAmQhvC8hx0O',	'sportovec',	'2026-01-22 17:15:27'),
(10,	'janhavlan',	'jan',	'havlan',	'$2y$10$YPirOv/e98hIlwR1g216KuBdtELfR9nUlh4pTGIbYRjKFi.lT3nKm',	'sportovec',	'2026-01-22 17:24:59');

CREATE TABLE `zpravy` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `odesilatel_id` int(11) NOT NULL,
  `prijemce_id` int(11) NOT NULL,
  `obsah` text COLLATE utf8_czech_ci NOT NULL,
  `datum` datetime DEFAULT CURRENT_TIMESTAMP,
  `precteno` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `odesilatel_id` (`odesilatel_id`),
  KEY `prijemce_id` (`prijemce_id`),
  CONSTRAINT `zpravy_ibfk_1` FOREIGN KEY (`odesilatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE,
  CONSTRAINT `zpravy_ibfk_2` FOREIGN KEY (`prijemce_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;


-- 2026-01-22 16:26:47
