-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Jan 15, 2019 at 12:44 AM
-- Server version: 5.7.19
-- PHP Version: 7.1.9

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

--
-- Database: `triatlon2019`
--
CREATE DATABASE IF NOT EXISTS `triatlon2019` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `triatlon2019`;

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

--
-- Table structure for table `deonice`
--

DROP TABLE IF EXISTS `deonice`;
CREATE TABLE IF NOT EXISTS `deonice` (
  `idDeonice` int(11) NOT NULL AUTO_INCREMENT,
  `deonica` varchar(15) NOT NULL,
  PRIMARY KEY (`idDeonice`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `deonice`
--

INSERT INTO `deonice` (`idDeonice`, `deonica`) VALUES
(1, 'plivanje'),
(2, 'T1'),
(3, 'biciklizam'),
(4, 'T2'),
(5, 'trcanje');

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

--
-- Table structure for table `ucesnici`
--

DROP TABLE IF EXISTS `ucesnici`;
CREATE TABLE IF NOT EXISTS `ucesnici` (
  `id` int(11) NOT NULL,
  `ime` varchar(120) NOT NULL,
  `drzava` varchar(120) NOT NULL,
  `diskvalifikovan` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `ucesnici`
--

INSERT INTO `ucesnici` (`id`, `ime`, `drzava`, `diskvalifikovan`) VALUES
(765, 'Kosta Mirkovic', 'Srbija', 0),
(1127, 'Tomislav Kostic', 'Srbija', 0),
(1221, 'Antonio Serrat Seoane', 'Spanija', 0),
(2354, 'Vladimir Srb', 'Ceska', 0),
(2873, 'Jonathan Brownlee', 'Velika Britanija', 1),
(3520, 'Fernando Alazra', 'Spanija', 0),
(4329, 'Marko Pavlovic', 'Srbija', 0),
(5060, 'Vincent Luis', 'Francuska', 0),
(6081, 'Mario Mola', 'Spanija', 0);

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

--
-- Table structure for table `vremena`
--

DROP TABLE IF EXISTS `vremena`;
CREATE TABLE IF NOT EXISTS `vremena` (
  `idVreme` int(11) NOT NULL AUTO_INCREMENT,
  `ucesnik` int(11) NOT NULL,
  `deonica` int(11) NOT NULL,
  `vreme` time(3) NOT NULL,
  PRIMARY KEY (`idVreme`),
  UNIQUE KEY `ucesnik_deonica` (`ucesnik`,`deonica`) USING BTREE,
  KEY `ucesnik` (`ucesnik`),
  KEY `deonica` (`deonica`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `vremena`
--

INSERT INTO `vremena` (`idVreme`, `ucesnik`, `deonica`, `vreme`) VALUES
(1, 1221, 1, '00:17:05.242'),
(2, 3520, 1, '00:17:05.998'),
(3, 4329, 1, '00:17:09.382'),
(4, 1127, 1, '00:17:10.018'),
(5, 5060, 1, '00:17:11.271'),
(6, 2354, 1, '00:17:14.982'),
(8, 765, 1, '00:17:22.781'),
(9, 6081, 1, '00:17:23.973'),
(10, 1221, 2, '00:02:15.087'),
(11, 3520, 2, '00:02:10.203'),
(12, 4329, 2, '00:01:50.982'),
(13, 1127, 2, '00:01:52.932'),
(14, 5060, 2, '00:01:59.450'),
(15, 2354, 2, '00:02:02.936'),
(16, 765, 2, '00:01:49.063'),
(17, 6081, 2, '00:01:58.448'),
(18, 1221, 3, '00:56:45.846'),
(19, 3520, 3, '00:58:02.853'),
(20, 4329, 3, '00:57:31.361'),
(21, 1127, 3, '00:55:59.632'),
(22, 5060, 3, '00:55:34.963'),
(23, 2354, 3, '00:56:02.974'),
(24, 765, 3, '00:55:54.024'),
(25, 6081, 3, '00:58:12.043'),
(26, 1221, 4, '00:01:12.823'),
(27, 3520, 4, '00:01:43.832'),
(28, 4329, 4, '00:01:11.042'),
(29, 1127, 4, '00:01:24.205'),
(30, 5060, 4, '00:01:56.962'),
(31, 2354, 4, '00:01:32.485'),
(32, 765, 4, '00:01:02.406'),
(33, 6081, 4, '00:01:12.048'),
(34, 765, 5, '00:33:51.726');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `vremena`
--
ALTER TABLE `vremena`
  ADD CONSTRAINT `fk_deonica` FOREIGN KEY (`deonica`) REFERENCES `deonice` (`idDeonice`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_ucesnik` FOREIGN KEY (`ucesnik`) REFERENCES `ucesnici` (`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 */;
