-- phpMyAdmin SQL Dump
-- version 4.1.14
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Sep 12, 2016 at 08:19 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: `ordinacija2016`
--
CREATE DATABASE IF NOT EXISTS `ordinacija2016` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `ordinacija2016`;

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

--
-- Table structure for table `izbor_lekara`
--

DROP TABLE IF EXISTS `izbor_lekara`;
CREATE TABLE IF NOT EXISTS `izbor_lekara` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_pacijent` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `id_lekar` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `datum_izbora` date NOT NULL COMMENT 'Datum kada je pacijent izabrao svog lekara.',
  `datum_isteka` date NOT NULL COMMENT 'Datum kada ističe odabir lekara (datum_odabira + godinu dana - 1 dan).',
  PRIMARY KEY (`id`),
  KEY `id_pacijent` (`id_pacijent`),
  KEY `id_lekar` (`id_lekar`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;

--
-- Dumping data for table `izbor_lekara`
--

INSERT INTO `izbor_lekara` (`id`, `id_pacijent`, `id_lekar`, `datum_izbora`, `datum_isteka`) VALUES
(1, 'drazen', 'macura', '2016-01-01', '2016-12-31'),
(2, 'sanja', 'kale', '2015-10-09', '2016-10-08'),
(3, 'bojan', 'kale', '2014-10-01', '2015-09-30'),
(4, 'bosko', 'macura', '2016-06-01', '2017-05-31'),
(5, 'miske', 'milan', '2015-09-01', '2016-08-31'),
(6, 'sofka', 'marijana', '2016-02-01', '2017-01-31'),
(7, 'filip', 'kale', '2016-01-01', '2016-12-31'),
(8, 'stubic', 'marijana', '2015-09-13', '2016-09-12'),
(9, 'bojovic', 'milan', '2016-07-01', '2017-06-30'),
(10, 'drazen', 'kale', '2015-01-01', '2015-12-31'),
(11, 'bosko', 'macura', '2015-06-01', '2016-05-31'),
(12, 'sanja', 'milan', '2014-10-09', '2015-10-08'),
(13, 'sjasa', 'macura', '2016-09-01', '2017-08-31');

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

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

DROP TABLE IF EXISTS `korisnik`;
CREATE TABLE IF NOT EXISTS `korisnik` (
  `korisnicko_ime` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `lozinka` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `ime` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `prezime` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `tip` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`korisnicko_ime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

INSERT INTO `korisnik` (`korisnicko_ime`, `lozinka`, `ime`, `prezime`, `tip`) VALUES
('bojan', 'sifra123', 'Bojan', 'Furlanović', 'p'),
('bojic', 'sifra123', 'Dragiša', 'Bojić', 'p'),
('bojovic', 'sifra123', 'Milorad', 'Bojović', 'p'),
('bosko', 'sifra123', 'Boško', 'Nikolić', 'p'),
('drazen', 'sifra123', 'Dražen', 'Drašković', 'p'),
('filip', 'sifra011011', 'Filip', 'Hadžipetrović', 'p'),
('kale', 'sifra12345', 'Kale', 'Gospodar Vremena', 'l'),
('kojic', 'sifra124', 'Novak', 'Kojić', 'p'),
('macura', 'sifra1234', 'Nada', 'Macura', 'l'),
('marijana', 'sifra1234', 'Marijana', 'Kovačević', 'l'),
('milan', 'sifra321', 'Milan', 'Tarot', 'l'),
('milana', 'bos1', 'Milana', 'Prodanović', 'p'),
('miske', 'papa123', 'Marko', 'Mišković - Papić', 'p'),
('sanja', 'sifra123', 'Sanja', 'Delčev', 'p'),
('sjasa', 'lozinka321', 'Aleksandar', 'Stojanović', 'p'),
('sofka', 'sifra123', 'Sofija', 'Šljokica', 'p'),
('stubic', 'stubic', 'Srećko', 'Tubić', 'p');

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

--
-- Table structure for table `sistem`
--

DROP TABLE IF EXISTS `sistem`;
CREATE TABLE IF NOT EXISTS `sistem` (
  `radno_vreme_od` time NOT NULL,
  `radno_vreme_do` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `sistem`
--

INSERT INTO `sistem` (`radno_vreme_od`, `radno_vreme_do`) VALUES
('08:00:00', '20:00:00');

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

--
-- Table structure for table `smena_lekar`
--

DROP TABLE IF EXISTS `smena_lekar`;
CREATE TABLE IF NOT EXISTS `smena_lekar` (
  `id_lekar` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `smena` tinyint(3) unsigned NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`),
  KEY `id_lekar` (`id_lekar`),
  KEY `id_lekar_2` (`id_lekar`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `smena_lekar`
--

INSERT INTO `smena_lekar` (`id_lekar`, `smena`, `id`) VALUES
('macura', 1, 1),
('marijana', 2, 2),
('kale', 1, 3),
('milan', 2, 4);

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

--
-- Table structure for table `termin`
--

DROP TABLE IF EXISTS `termin`;
CREATE TABLE IF NOT EXISTS `termin` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `id_pacijenta` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `id_lekara` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `datum` date NOT NULL,
  `vreme` time NOT NULL,
  `tip_pregleda` int(10) unsigned NOT NULL,
  `otkazan` tinyint(3) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id_pacijenta` (`id_pacijenta`),
  KEY `id_lekara` (`id_lekara`),
  KEY `tip_pregleda` (`tip_pregleda`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;

--
-- Dumping data for table `termin`
--

INSERT INTO `termin` (`id`, `id_pacijenta`, `id_lekara`, `datum`, `vreme`, `tip_pregleda`, `otkazan`) VALUES
(9, 'sanja', 'milan', '2014-12-31', '19:00:00', 3, 0),
(10, 'drazen', 'macura', '2016-09-13', '08:00:00', 1, 0),
(11, 'bosko', 'macura', '2016-09-13', '08:15:00', 2, 0),
(12, 'bosko', 'macura', '2016-09-12', '12:00:00', 2, 1),
(13, 'miske', 'milan', '2015-12-31', '18:00:00', 3, 0),
(14, 'drazen', 'kale', '2015-10-01', '08:00:00', 2, 0),
(15, 'sofka', 'marijana', '2016-10-03', '14:00:00', 3, 0),
(16, 'sjasa', 'macura', '2016-09-13', '13:00:00', 4, 0);

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

--
-- Table structure for table `tip_pregleda`
--

DROP TABLE IF EXISTS `tip_pregleda`;
CREATE TABLE IF NOT EXISTS `tip_pregleda` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `naziv` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `trajanje` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `tip_pregleda`
--

INSERT INTO `tip_pregleda` (`id`, `naziv`, `trajanje`) VALUES
(1, 'kontrola', 10),
(2, 'opšti pregled', 15),
(3, 'specijalistički pregled', 25),
(4, 'ultrazvuk', 20);

--
-- Constraints for dumped tables
--

--
-- Constraints for table `izbor_lekara`
--
ALTER TABLE `izbor_lekara`
  ADD CONSTRAINT `FK_lekar` FOREIGN KEY (`id_lekar`) REFERENCES `korisnik` (`korisnicko_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pacijent` FOREIGN KEY (`id_pacijent`) REFERENCES `korisnik` (`korisnicko_ime`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `smena_lekar`
--
ALTER TABLE `smena_lekar`
  ADD CONSTRAINT `FK_lekar_smena` FOREIGN KEY (`id_lekar`) REFERENCES `korisnik` (`korisnicko_ime`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `termin`
--
ALTER TABLE `termin`
  ADD CONSTRAINT `FK_tip_pregleda` FOREIGN KEY (`tip_pregleda`) REFERENCES `tip_pregleda` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_lekar_termin` FOREIGN KEY (`id_lekara`) REFERENCES `korisnik` (`korisnicko_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_pacijent_termin` FOREIGN KEY (`id_pacijenta`) REFERENCES `korisnik` (`korisnicko_ime`) 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 */;
