-- phpMyAdmin SQL Dump
-- version 3.5.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 04, 2014 at 08:24 AM
-- Server version: 5.5.24-log
-- PHP Version: 5.4.3

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: `sp2014`
--
CREATE DATABASE `sp2014` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `sp2014`;

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

--
-- Table structure for table `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,
  `godinarodjenja` int(11) NOT NULL,
  `is_admin` 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`, `godinarodjenja`, `is_admin`) VALUES
('admin', 'sifra123', 'Admin', 'Adminski', 1966, 1),
('bleki', 'sifra123', 'Vladimir', 'Blagojevic', 1950, 0),
('bosko', 'sifra123', 'Bosko', 'Nikolic', 1972, 0),
('drasko', 'sifra123', 'Drazen', 'Draskovic', 1986, 0);

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

--
-- Table structure for table `stavkatiketa`
--

CREATE TABLE IF NOT EXISTS `stavkatiketa` (
  `idstavke` int(11) NOT NULL AUTO_INCREMENT,
  `idt` int(11) NOT NULL,
  `idu` int(11) NOT NULL,
  `tip` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idstavke`),
  KEY `idt` (`idt`,`idu`),
  KEY `idu` (`idu`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=12 ;

--
-- Dumping data for table `stavkatiketa`
--

INSERT INTO `stavkatiketa` (`idstavke`, `idt`, `idu`, `tip`) VALUES
(1, 1, 1, 'x'),
(2, 1, 2, '1'),
(3, 1, 3, '1'),
(4, 2, 1, '2'),
(5, 2, 4, '2'),
(6, 3, 1, '1'),
(7, 3, 2, '1'),
(8, 4, 5, 'x'),
(9, 4, 6, '1'),
(10, 5, 5, '1'),
(11, 5, 6, 'x');

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

--
-- Table structure for table `tiket`
--

CREATE TABLE IF NOT EXISTS `tiket` (
  `idtiket` int(11) NOT NULL AUTO_INCREMENT,
  `idkorisnik` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `uplata` double NOT NULL,
  `dobitnitiket` int(11) DEFAULT NULL,
  `dobitak` int(11) DEFAULT NULL,
  PRIMARY KEY (`idtiket`),
  KEY `idkorisnik` (`idkorisnik`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;

--
-- Dumping data for table `tiket`
--

INSERT INTO `tiket` (`idtiket`, `idkorisnik`, `uplata`, `dobitnitiket`, `dobitak`) VALUES
(1, 'bosko', 1000, NULL, NULL),
(2, 'drasko', 500, NULL, NULL),
(3, 'bleki', 3000, NULL, NULL),
(4, 'bosko', 400, 0, 0),
(5, 'drasko', 200, 1, 1233);

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

--
-- Table structure for table `utakmica`
--

CREATE TABLE IF NOT EXISTS `utakmica` (
  `idu` int(11) NOT NULL AUTO_INCREMENT,
  `domacin` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `gost` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `datum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `kvota1` double NOT NULL,
  `kvotax` double NOT NULL,
  `kvota2` double NOT NULL,
  `rezultat` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
  `tip` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idu`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;

--
-- Dumping data for table `utakmica`
--

INSERT INTO `utakmica` (`idu`, `domacin`, `gost`, `datum`, `kvota1`, `kvotax`, `kvota2`, `rezultat`, `tip`) VALUES
(1, 'Francuska', 'Nemacka', '2014-07-04 16:00:00', 3, 3.2, 2.63, '', ''),
(2, 'Brazil', 'Kolumbija', '2014-07-04 20:00:00', 1.85, 3.7, 4.75, '', ''),
(3, 'Argentina', 'Belgija', '2014-07-05 16:00:00', 2.2, 3.3, 3.75, '', ''),
(4, 'Holandija', 'Kostarika', '2014-07-19 20:00:00', 1.5, 4.33, 8, '', ''),
(5, 'Francuska', 'Nigerija', '2014-07-01 16:00:00', 1.45, 4.75, 6, '2:0', '1'),
(6, 'Nemacka', 'Alzir', '2014-07-04 08:11:10', 1.6, 4.25, 5.85, '0:0', 'x');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `stavkatiketa`
--
ALTER TABLE `stavkatiketa`
  ADD CONSTRAINT `stavkatiketa_ibfk_2` FOREIGN KEY (`idu`) REFERENCES `utakmica` (`idu`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `stavkatiketa_ibfk_1` FOREIGN KEY (`idt`) REFERENCES `tiket` (`idtiket`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `tiket`
--
ALTER TABLE `tiket`
  ADD CONSTRAINT `tiket_ibfk_1` FOREIGN KEY (`idkorisnik`) REFERENCES `korisnik` (`korisnickoime`) ON DELETE 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 */;
