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