-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Jun 12, 2015 at 11:33 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: `dezurstva`
--

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

--
-- Table structure for table `asistent`
--

CREATE TABLE IF NOT EXISTS `asistent` (
  `username` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `katedra` varchar(3) COLLATE utf8_unicode_ci NOT NULL,
  `is_admin` tinyint(4) NOT NULL,
  PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `asistent`
--

INSERT INTO `asistent` (`username`, `password`, `ime`, `prezime`, `katedra`, `is_admin`) VALUES
('aca', 'sifra123', 'Aca', 'Tatalovic', 'EPP', 0),
('alekic', 'sifra123', 'Aleksandra', 'Lekic', 'EL', 0),
('aleksandra', 'sifra123', 'Aleksandra', 'Marjanovic', 'SIS', 0),
('drasko', 'sifra123', 'Drazen', 'Draskovic', 'RTI', 0),
('gaga', 'sifra123', 'Dragomir', 'El Mezeni', 'EL', 0),
('kostaj', 'sifra123', 'Kosta', 'Jovanovic', 'SIS', 0),
('krneta', 'sifra123', 'Aleksandra', 'Krneta', 'OET', 0),
('milanka', 'sifra123', 'Milanka', 'Studenski Odsek', 'SO', 1),
('neca', 'sifra123', 'Nemanja', 'Kojic', 'RTI', 0);

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

--
-- Table structure for table `dezurstvo`
--

CREATE TABLE IF NOT EXISTS `dezurstvo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `rok` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `datum` date NOT NULL,
  `pocetak` time NOT NULL,
  `predmet` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `sala` int(11) NOT NULL,
  `dezurni` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `za_zamenu` tinyint(4) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `predmet` (`predmet`,`dezurni`),
  KEY `dezurni` (`dezurni`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;

--
-- Dumping data for table `dezurstvo`
--

INSERT INTO `dezurstvo` (`id`, `rok`, `datum`, `pocetak`, `predmet`, `sala`, `dezurni`, `za_zamenu`) VALUES
(1, 'Jun 2015', '2015-06-10', '18:30:00', 'OO1ORT', 56, 'aleksandra', 1),
(2, 'Jun 2015', '2015-06-17', '11:30:00', 'IR2RM1', 26, 'drasko', 0),
(3, 'Jun 2015', '2015-06-13', '00:00:15', 'OS4IP', 25, 'kostaj', 0),
(4, 'Jun 2015', '2015-06-13', '00:00:15', 'IR4PIA', 60, 'aca', 1),
(5, 'Jun 2015', '2015-06-19', '11:30:00', 'OO1M1', 56, 'neca', 1),
(6, 'Jun 2015', '2015-06-21', '00:00:08', 'SI3TS', 65, 'drasko', 1);

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

--
-- Table structure for table `predmet`
--

CREATE TABLE IF NOT EXISTS `predmet` (
  `sifra` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `naziv` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`sifra`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `predmet`
--

INSERT INTO `predmet` (`sifra`, `naziv`) VALUES
('IR2RM1', 'Racunarske mreze 1'),
('IR4PIA', 'Programiranje internet aplikacija'),
('OE2OOP', 'Objektno orijentisano programiranje'),
('OO1M1', 'Matematika 1'),
('OO1ORT', 'Osnovi racunarske tehnike'),
('OO1P1', 'Programiranje 1'),
('OO1P2', 'Programiranje 2'),
('OS2SIS', 'Signali i sistemi'),
('OS4IP', 'Internet programiranje'),
('SI3TS', 'Testiranje softvera');

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

--
-- Table structure for table `zamena_ponude`
--

CREATE TABLE IF NOT EXISTS `zamena_ponude` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `davalac_user` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `primalac_user` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `id_dez_ustupljenog` int(11) NOT NULL,
  `id_dez_preuzetog` int(11) NOT NULL,
  `potvrdjeno` tinyint(4) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `davalac_user` (`davalac_user`,`primalac_user`,`id_dez_ustupljenog`,`id_dez_preuzetog`),
  KEY `primalac_user` (`primalac_user`),
  KEY `id_dez_ustupljenog` (`id_dez_ustupljenog`),
  KEY `id_dez_preuzetog` (`id_dez_preuzetog`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;

--
-- Dumping data for table `zamena_ponude`
--

INSERT INTO `zamena_ponude` (`id`, `davalac_user`, `primalac_user`, `id_dez_ustupljenog`, `id_dez_preuzetog`, `potvrdjeno`) VALUES
(1, 'aleksandra', 'aca', 1, 4, 1),
(2, 'neca', 'drasko', 5, 6, 0);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `dezurstvo`
--
ALTER TABLE `dezurstvo`
  ADD CONSTRAINT `dezurstvo_ibfk_1` FOREIGN KEY (`predmet`) REFERENCES `predmet` (`sifra`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `dezurstvo_ibfk_2` FOREIGN KEY (`dezurni`) REFERENCES `asistent` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `zamena_ponude`
--
ALTER TABLE `zamena_ponude`
  ADD CONSTRAINT `zamena_ponude_ibfk_4` FOREIGN KEY (`id_dez_preuzetog`) REFERENCES `dezurstvo` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `zamena_ponude_ibfk_1` FOREIGN KEY (`davalac_user`) REFERENCES `asistent` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `zamena_ponude_ibfk_2` FOREIGN KEY (`primalac_user`) REFERENCES `asistent` (`username`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `zamena_ponude_ibfk_3` FOREIGN KEY (`id_dez_ustupljenog`) REFERENCES `dezurstvo` (`id`) 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 */;
