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

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

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

DROP TABLE IF EXISTS `korisnik`;
CREATE TABLE IF NOT EXISTS `korisnik` (
  `korisnicko_ime` varchar(50) NOT NULL,
  `lozinka` varchar(50) NOT NULL,
  `ime` varchar(50) NOT NULL,
  `prezime` varchar(50) NOT NULL,
  `telefon` varchar(15) NOT NULL,
  PRIMARY KEY (`korisnicko_ime`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

INSERT INTO `korisnik` (`korisnicko_ime`, `lozinka`, `ime`, `prezime`, `telefon`) VALUES
('bosko', 'sifra123', 'Bosko', 'Nikolic', '+381690987654'),
('drazen', 'sifra123', 'Drazen', 'Draskovic', '+381601234567'),
('janko', 'sifra123', 'Janko', 'Jankovic', '+38166778899'),
('micko', 'sifra123', 'Milos', 'Micovic', '+381612345678'),
('pera', 'sifra123', 'Petar', 'Petrovic', '+38165789012'),
('rade', 'sifra123', 'Radivoje', 'Radenkovic', '+381623456789'),
('sumi', 'sifra123', 'Milos', 'Markovic', '+38164567890');

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

--
-- Table structure for table `oglas`
--

DROP TABLE IF EXISTS `oglas`;
CREATE TABLE IF NOT EXISTS `oglas` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `marka` varchar(20) NOT NULL,
  `model` varchar(50) NOT NULL,
  `cena` int(10) NOT NULL,
  `godiste` varchar(4) NOT NULL,
  `region` int(10) NOT NULL,
  `datum` date NOT NULL,
  `opis` text NOT NULL,
  `prodat` tinyint(1) NOT NULL,
  `oglasivac` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `region` (`region`),
  KEY `oglasivac` (`oglasivac`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

--
-- Dumping data for table `oglas`
--

INSERT INTO `oglas` (`id`, `marka`, `model`, `cena`, `godiste`, `region`, `datum`, `opis`, `prodat`, `oglasivac`) VALUES
(1, 'Fiat', '500', 5000, '2008', 1, '2017-06-12', 'Crvene boje, benzinac, presao 130.000km.\r\nRegistrovan, prvi vlasnik. Imao manju ogrebotinu, prefarban.', 0, 'micko'),
(2, 'Opel', 'Corsa', 7000, '2011', 1, '2017-05-28', 'Crvene boje, odlicno ocuvan, prosao tehnicki pregled, registrovan. Benzinac, potrosnja 9l u gradu, 6l na otvorenom. Ima tempomat.', 0, 'drazen'),
(3, 'Ford', 'Focus', 1700, '2001', 7, '2017-05-12', 'Teget boje, benzinac, uvezen iz Svajcarske. Imao manje ostecenje koje je sanirano. Nedostaje mu akumulator. Ima klimu.', 1, 'janko'),
(4, 'Toyota', 'Yaris', 4000, '2004', 9, '2017-06-10', 'Stari model, metalik sive boje. Presao 150.000km, u dobrom voznom stanju. Ima klimu i radio, uz kola prodajem i zimske gume. Moguc dogovor.', 0, 'pera'),
(5, 'BMW', 'X5', 70000, '2004', 1, '2017-06-06', 'Crn, zatamnjena stakla, kozna sedista. Dizel.', 0, 'pera'),
(6, 'Opel', 'Astra', 3000, '2005', 1, '2017-06-12', 'Metalik plava boja, karavan, benzin + TNG, presao 200.000km. Klima, radio. Registrovan.', 0, 'sumi'),
(7, 'Fiat', 'Brava', 1200, '1998', 1, '2017-06-15', 'Teget, benzinac, u dobrom voznom stanju. Jedino jedan prozor ne moze da se otvori. 5 vrata.', 0, 'pera'),
(8, 'Ford', 'Fiesta', 3350, '2005', 2, '2017-05-29', 'Crvene boje, ima svetla za maglu, benzin, presao 141.000km, registrovan.', 1, 'janko'),
(9, 'Fiat', 'Punto', 1700, '2004', 2, '2017-06-19', 'Svetlo plave boje, benzin, registrovan, presao 137.000km. Ima klimu, 5 vrata.', 1, 'micko'),
(10, 'Fiat', 'Punto', 1400, '2002', 2, '2017-06-17', 'Sivi, benzinac, 110.000km, 5 vrata. Klima i radio.', 0, 'micko');

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

--
-- Table structure for table `omiljeni`
--

DROP TABLE IF EXISTS `omiljeni`;
CREATE TABLE IF NOT EXISTS `omiljeni` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `oglas` int(10) NOT NULL,
  `korisnik` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `oglas` (`oglas`,`korisnik`),
  KEY `korisnik` (`korisnik`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

--
-- Dumping data for table `omiljeni`
--

INSERT INTO `omiljeni` (`id`, `oglas`, `korisnik`) VALUES
(6, 3, 'micko'),
(1, 5, 'bosko'),
(5, 5, 'sumi'),
(4, 7, 'janko'),
(7, 8, 'micko'),
(2, 9, 'janko'),
(3, 10, 'janko');

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

--
-- Table structure for table `region`
--

DROP TABLE IF EXISTS `region`;
CREATE TABLE IF NOT EXISTS `region` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `naziv` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;

--
-- Dumping data for table `region`
--

INSERT INTO `region` (`id`, `naziv`) VALUES
(1, 'Beograd'),
(2, 'Vojvodina'),
(5, 'Macva'),
(6, 'Zlatibor'),
(7, 'Sumadija'),
(8, 'Podunavlje'),
(9, 'Kopaonik'),
(10, 'Nis'),
(11, 'Pomoravlje'),
(12, 'Bor');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `oglas`
--
ALTER TABLE `oglas`
  ADD CONSTRAINT `FK_oglas_korisnik` FOREIGN KEY (`oglasivac`) REFERENCES `korisnik` (`korisnicko_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_oglas_region` FOREIGN KEY (`region`) REFERENCES `region` (`id`) ON UPDATE CASCADE;

--
-- Constraints for table `omiljeni`
--
ALTER TABLE `omiljeni`
  ADD CONSTRAINT `FK_omiljeni_korisnik` FOREIGN KEY (`korisnik`) REFERENCES `korisnik` (`korisnicko_ime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_omiljeni_oglas` FOREIGN KEY (`oglas`) REFERENCES `oglas` (`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 */;
