-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 06, 2016 at 03:41 AM
-- Server version: 5.6.17
-- PHP Version: 5.5.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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 utf8 */;

--
-- Database: `atp2016`
--
CREATE DATABASE IF NOT EXISTS `atp2016` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `atp2016`;

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

--
-- Table structure for table `korisnik`
--

DROP TABLE IF EXISTS `korisnik`;
CREATE TABLE IF NOT EXISTS `korisnik` (
  `korisnickoime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `lozinka` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `telefon` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `je_organizator` tinyint(4) NOT NULL,
  PRIMARY KEY (`korisnickoime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `korisnik`
--

INSERT INTO `korisnik` (`korisnickoime`, `lozinka`, `ime`, `prezime`, `telefon`, `je_organizator`) VALUES
('australian', 'sifra123', 'Rod', 'Laver', '0601122334', 1),
('belgrade', 'sifra123', 'Boba', 'Zivojinovic', '8833366600', 1),
('drasko', 'sifra123', 'Drazen', 'Draskovic', '0641234567', 0),
('madrid', 'sifra123', 'Carlos', 'Santana', '07011223345', 1),
('roland', 'sifra123', 'Napoleon', 'Bonaparta', '0611122334', 1),
('rome', 'sifra123', 'Eros', 'Ramazzoti', '9055667788', 1),
('sanja', 'sifra123', 'Sanja', 'Delcev', '0693344555', 0),
('usopen', 'sifra123', 'Andre', 'Agassi', '08011223344', 1),
('wimbledon', 'sifra123', 'Elizabeta', 'Windsor', '0631122334', 1);

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

--
-- Table structure for table `teniser`
--

DROP TABLE IF EXISTS `teniser`;
CREATE TABLE IF NOT EXISTS `teniser` (
  `idteniser` int(11) NOT NULL AUTO_INCREMENT,
  `ime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `godinarodjenja` int(11) NOT NULL,
  `zemlja` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idteniser`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=18 ;

--
-- Dumping data for table `teniser`
--

INSERT INTO `teniser` (`idteniser`, `ime`, `prezime`, `godinarodjenja`, `zemlja`) VALUES
(1, 'Andy', 'Murray', 1987, 'UK'),
(2, 'Dominic', 'Thiem', 1994, 'Austrija'),
(3, 'Kei', 'Nishikori', 1990, 'Japan'),
(4, 'Novak', 'Djokovic', 1987, 'Srbija'),
(5, 'Rafael', 'Nadal', 1986, 'Spanija'),
(6, 'Richard', 'Gasquet', 1987, 'Francuska'),
(7, 'Joe', 'Tsonga', 1990, 'Francuska'),
(8, 'Roger', 'Federer', 1981, 'Svajcarska'),
(9, 'Stan', 'Wawrinka', 1985, 'Svajcarska'),
(10, 'Tomas', 'Berdych', 1986, 'Ceska republika'),
(11, 'Milos', 'Raonic', 1991, 'Kanada'),
(12, 'Viktor', 'Troicki', 1986, 'Srbija'),
(13, 'Janko', 'Tipsarevic', 1984, 'Srbija'),
(14, 'Gilles', 'Simon', 1985, 'Francuska'),
(15, 'Gael', 'Monfis', 1986, 'Francuska'),
(16, 'David', 'Ferrer', 1982, 'Spanija');

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

--
-- Table structure for table `turnir`
--

DROP TABLE IF EXISTS `turnir`;
CREATE TABLE IF NOT EXISTS `turnir` (
  `idturnir` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `datum_pocetka` date NOT NULL,
  `datum_kraja` date NOT NULL,
  `tip` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `W` int(11) NOT NULL,
  `F` int(11) NOT NULL,
  `S` int(11) NOT NULL,
  `Q` int(11) NOT NULL,
  `korisnickoime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idturnir`),
  KEY `korisnickoime` (`korisnickoime`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=8 ;

--
-- Dumping data for table `turnir`
--

INSERT INTO `turnir` (`idturnir`, `naziv`, `datum_pocetka`, `datum_kraja`, `tip`, `W`, `F`, `S`, `Q`, `korisnickoime`) VALUES
(1, 'Australian Open 2016', '2016-01-18', '2016-01-31', 'GrandSlam', 2000, 1200, 720, 360, 'australian'),
(2, 'Roland Garros', '2016-05-23', '2016-06-07', 'GrandSlam', 2000, 1200, 720, 360, 'roland'),
(3, 'Wimbledon 2015', '2015-06-29', '2015-07-12', 'GrandSlam', 2000, 1200, 720, 360, 'wimbledon'),
(4, 'US Open', '2015-08-31', '2015-09-13', 'GrandSlam', 2000, 1200, 720, 360, 'usopen'),
(5, 'Belgrade Open 2016', '2016-05-01', '2016-05-08', 'Masters500', 500, 300, 180, 90, 'belgrade'),
(6, 'Madrid Open', '2016-05-01', '2016-05-08', 'Masters1000', 1000, 600, 360, 180, 'madrid'),
(7, 'Rome Open', '2016-05-08', '2016-05-15', 'Masters1000', 1000, 600, 360, 180, 'rome');

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

--
-- Table structure for table `uspeh`
--

DROP TABLE IF EXISTS `uspeh`;
CREATE TABLE IF NOT EXISTS `uspeh` (
  `iduspeh` int(11) NOT NULL AUTO_INCREMENT,
  `idteniser` int(11) NOT NULL,
  `idturnir` int(11) NOT NULL,
  `rezultat` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`iduspeh`),
  KEY `idteniser` (`idteniser`),
  KEY `idturnir` (`idturnir`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=25 ;

--
-- Dumping data for table `uspeh`
--

INSERT INTO `uspeh` (`iduspeh`, `idteniser`, `idturnir`, `rezultat`) VALUES
(1, 4, 3, 'W'),
(2, 8, 3, 'F'),
(3, 1, 3, 'S'),
(4, 6, 3, 'S'),
(5, 6, 3, 'Q'),
(6, 9, 3, 'Q'),
(7, 12, 3, 'Q'),
(8, 14, 3, 'Q'),
(9, 4, 4, 'W'),
(10, 8, 4, 'F'),
(11, 7, 4, 'S'),
(12, 9, 4, 'S'),
(13, 6, 4, 'Q'),
(14, 10, 4, 'Q'),
(15, 15, 4, 'Q'),
(16, 16, 4, 'Q'),
(17, 4, 6, 'W'),
(18, 3, 6, 'F'),
(19, 5, 6, 'S'),
(20, 11, 6, 'S'),
(21, 6, 6, 'Q'),
(22, 7, 6, 'Q'),
(23, 2, 6, 'Q'),
(24, 9, 6, 'Q');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `turnir`
--
ALTER TABLE `turnir`
  ADD CONSTRAINT `turnir_ibfk_1` FOREIGN KEY (`korisnickoime`) REFERENCES `korisnik` (`korisnickoime`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `uspeh`
--
ALTER TABLE `uspeh`
  ADD CONSTRAINT `uspeh_ibfk_2` FOREIGN KEY (`idturnir`) REFERENCES `turnir` (`idturnir`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `uspeh_ibfk_1` FOREIGN KEY (`idteniser`) REFERENCES `teniser` (`idteniser`) ON DELETE CASCADE ON UPDATE CASCADE;

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