-- 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;

TRUNCATE `anketa_hlasy`;

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;

TRUNCATE `anketa_moznosti`;

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,
  `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;

TRUNCATE `ankety`;

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;

TRUNCATE `clenove_tymu`;

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') COLLATE utf8_czech_ci DEFAULT 'nepritomen',
  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;

TRUNCATE `dochazka`;

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;

TRUNCATE `poznamky`;

CREATE TABLE `statistiky_hodnoty` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uzivatel_id` int(11) NOT NULL,
  `stat_typ_id` int(11) NOT NULL,
  `hodnota` int(11) DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `uzivatel_id` (`uzivatel_id`),
  KEY `stat_typ_id` (`stat_typ_id`),
  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;

TRUNCATE `statistiky_hodnoty`;

CREATE TABLE `statistiky_typy` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tym_id` int(11) NOT NULL DEFAULT '1',
  `nazev` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tym_id` (`tym_id`),
  CONSTRAINT `statistiky_typy_ibfk_1` FOREIGN KEY (`tym_id`) REFERENCES `tymy` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

TRUNCATE `statistiky_typy`;

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 NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

TRUNCATE `tymy`;

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;

TRUNCATE `udalosti`;

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',
  `vytvoril_uzivatel_id` int(11) DEFAULT NULL,
  `datum_registrace` datetime DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`uzivatelske_jmeno`),
  KEY `vytvoril_uzivatel_id` (`vytvoril_uzivatel_id`),
  CONSTRAINT `uzivatele_ibfk_1` FOREIGN KEY (`vytvoril_uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

TRUNCATE `uzivatele`;
INSERT INTO `uzivatele` (`id`, `uzivatelske_jmeno`, `jmeno`, `prijmeni`, `heslo`, `role`, `vytvoril_uzivatel_id`, `datum_registrace`) VALUES
(1,	'admin',	'Admin',	'Systémový',	'$2y$10$xVzTxZyh4YM5pIvm8feFlOJj546/WO63vssya984OSjd/HNvJzuB2',	'admin',	1,	'2025-12-17 17:20:25');

CREATE TABLE `zpravy` (
  `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 `zpravy_ibfk_1` FOREIGN KEY (`tym_id`) REFERENCES `tymy` (`id`) ON DELETE CASCADE,
  CONSTRAINT `zpravy_ibfk_2` FOREIGN KEY (`uzivatel_id`) REFERENCES `uzivatele` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;

TRUNCATE `zpravy`;

-- 2026-04-09 22:38:59
