-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: May 07, 2016 at 01:42 PM
-- 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: `elektrijada2016`
--
CREATE DATABASE IF NOT EXISTS `elektrijada2016` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `elektrijada2016`;

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

--
-- Table structure for table `prijava`
--

DROP TABLE IF EXISTS `prijava`;
CREATE TABLE IF NOT EXISTS `prijava` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `brojpasosa` int(11) NOT NULL,
  `vrstaputnika` int(11) NOT NULL,
  `disciplina` int(11) DEFAULT NULL,
  `vrstasmestaja` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `prevoz` tinyint(1) NOT NULL,
  `naplaceno` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `username` (`username`,`disciplina`,`vrstasmestaja`),
  KEY `disciplina` (`disciplina`),
  KEY `vrstasmestaja` (`vrstasmestaja`),
  KEY `username_2` (`username`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;

--
-- Dumping data for table `prijava`
--

INSERT INTO `prijava` (`id`, `username`, `brojpasosa`, `vrstaputnika`, `disciplina`, `vrstasmestaja`, `prevoz`, `naplaceno`) VALUES
(1, 'dd125050p@student.etf.rs', 1234567, 3, 2, 'PUN', 0, 1),
(2, 'ss153344m@student.etf.rs', 3344556, 1, 4, 'PP', 1, 1),
(3, 'ii140456d@student.etf.rs', 23456780, 4, NULL, 'ND', 1, 0),
(4, 'jj120321d@student.etf.rs', 3456787, 4, NULL, 'PUN', 1, 0);

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

--
-- Table structure for table `student`
--

DROP TABLE IF EXISTS `student`;
CREATE TABLE IF NOT EXISTS `student` (
  `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,
  `datumrodj` date NOT NULL,
  `studije` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
  `racun` double NOT NULL,
  `je_organizator` tinyint(1) NOT NULL,
  PRIMARY KEY (`korisnickoime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `student`
--

INSERT INTO `student` (`korisnickoime`, `lozinka`, `ime`, `prezime`, `datumrodj`, `studije`, `racun`, `je_organizator`) VALUES
('dd125050p@student.etf.rs', 'sifra123', 'Drasko', 'Draskovic', '1987-07-07', 'PHD', 456.8, 0),
('ii140456d@student.etf.rs', 'sifra123', 'Ivan', 'Ivanovic', '1995-01-01', 'D', 0, 0),
('jj120321d@student.etf.rs', 'sifra123', 'Jovan', 'Jovanovic', '1992-06-06', 'D', 19760, 0),
('pp110123d@student.etf.rs', 'sifra123', 'Petar', 'Petrovic', '1994-05-04', 'D', 18500, 0),
('ss140444d@student.etf.rs', 'sifra123', 'Stefan', 'Stefanovic', '1995-05-05', 'D', 12450.65, 0),
('ss153344m@student.etf.rs', 'sifra123', 'Sanja', 'Sanjarevic', '1990-10-10', 'MAS', 7450, 0),
('tt110555d@student.etf.rs', 'sifra123', 'Student', 'Prodekanica', '1993-03-08', 'D', 25000, 1);

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

--
-- Table structure for table `vrstadiscipline`
--

DROP TABLE IF EXISTS `vrstadiscipline`;
CREATE TABLE IF NOT EXISTS `vrstadiscipline` (
  `iddisc` int(11) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`iddisc`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=8 ;

--
-- Dumping data for table `vrstadiscipline`
--

INSERT INTO `vrstadiscipline` (`iddisc`, `naziv`) VALUES
(1, 'automatika'),
(2, 'informatika'),
(4, 'elektronika'),
(5, 'objektno programiranje'),
(6, 'matematika'),
(7, 'fizika');

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

--
-- Table structure for table `vrstasmestaja`
--

DROP TABLE IF EXISTS `vrstasmestaja`;
CREATE TABLE IF NOT EXISTS `vrstasmestaja` (
  `vrsta` varchar(4) COLLATE utf8_unicode_ci NOT NULL,
  `punnaziv` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `cena` double NOT NULL,
  PRIMARY KEY (`vrsta`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `vrstasmestaja`
--

INSERT INTO `vrstasmestaja` (`vrsta`, `punnaziv`, `cena`) VALUES
('ND', 'Nocenje sa doruckom', 5000),
('PP', 'Polupansion', 7500),
('PUN', 'Pun pansion', 9500);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `prijava`
--
ALTER TABLE `prijava`
  ADD CONSTRAINT `prijava_ibfk_1` FOREIGN KEY (`disciplina`) REFERENCES `vrstadiscipline` (`iddisc`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `prijava_ibfk_2` FOREIGN KEY (`vrstasmestaja`) REFERENCES `vrstasmestaja` (`vrsta`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `prijava_ibfk_3` FOREIGN KEY (`username`) REFERENCES `student` (`korisnickoime`) 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 */;
