-- phpMyAdmin SQL Dump
-- version 4.7.9
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Aug 24, 2019 at 11:59 AM
-- Server version: 5.7.21
-- PHP Version: 7.2.4
-- Autor: Drazen

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
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 utf8mb4 */;

--
-- Database: `autoprodaja2019jsf`
--
DROP DATABASE IF EXISTS `autoprodaja2019jsf`;
CREATE DATABASE IF NOT EXISTS `autoprodaja2019jsf` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `autoprodaja2019jsf`;

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

--
-- Table structure for table `kupac`
--

DROP TABLE IF EXISTS `kupac`;
CREATE TABLE IF NOT EXISTS `kupac` (
  `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,
  `godinar` int(11) NOT NULL,
  PRIMARY KEY (`korisnickoime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `kupac`
--

INSERT INTO `kupac` (`korisnickoime`, `lozinka`, `ime`, `prezime`, `godinar`) VALUES
('bogdan', 'sifra123', 'Bogdan', 'Bogdanovic', 1992),
('nemanja', 'sifra123', 'Nemanja', 'Bjelica', 1988),
('nikola', 'sifra123', 'Nikola', 'Jokic', 1995),
('sasa', 'sifra123', 'Aleksandar', 'Djordjevic', 1967);

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

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

DROP TABLE IF EXISTS `oglas`;
CREATE TABLE IF NOT EXISTS `oglas` (
  `idOg` int(11) NOT NULL AUTO_INCREMENT,
  `marka` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `model` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `motor` double NOT NULL,
  `godiste` int(11) NOT NULL,
  `kilometraza` int(11) NOT NULL,
  `pocetnaCena` int(11) NOT NULL,
  `datumIstek` date NOT NULL,
  `idProdavac` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`idOg`),
  KEY `fk_prodavac_idProdavac` (`idProdavac`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

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

INSERT INTO `oglas` (`idOg`, `marka`, `model`, `motor`, `godiste`, `kilometraza`, `pocetnaCena`, `datumIstek`, `idProdavac`) VALUES
(1, 'Volskwagen', 'Passat', 1.9, 2015, 167500, 14000, '2019-08-20', 'autokomerc'),
(2, 'Audi', 'A5', 2, 2017, 69000, 32999, '2019-08-26', 'autokomerc'),
(3, 'Opel', 'Astra', 1.4, 2018, 44788, 16777, '2019-08-27', 'autosava'),
(4, 'Mercedes', 'GLA200', 2.2, 2016, 119800, 20850, '2019-08-28', 'autosava');

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

--
-- Table structure for table `ponuda`
--

DROP TABLE IF EXISTS `ponuda`;
CREATE TABLE IF NOT EXISTS `ponuda` (
  `idPonuda` int(11) NOT NULL AUTO_INCREMENT,
  `idOglas` int(11) NOT NULL,
  `idKupac` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `iznos` int(11) NOT NULL,
  PRIMARY KEY (`idPonuda`),
  KEY `fk_oglas_idOglas` (`idOglas`),
  KEY `fk_kupac_idKupac` (`idKupac`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `ponuda`
--

INSERT INTO `ponuda` (`idPonuda`, `idOglas`, `idKupac`, `iznos`) VALUES
(1, 1, 'nemanja', 14700),
(2, 1, 'bogdan', 14705),
(3, 2, 'nikola', 33300);

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

--
-- Table structure for table `prodavac`
--

DROP TABLE IF EXISTS `prodavac`;
CREATE TABLE IF NOT EXISTS `prodavac` (
  `korisnickoime` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `lozinka` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `naziv` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
  `PIB` varchar(9) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`korisnickoime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `prodavac`
--

INSERT INTO `prodavac` (`korisnickoime`, `lozinka`, `naziv`, `PIB`) VALUES
('autokomerc', 'autokomerc123', 'Autokomerc Beograd', '111222333'),
('autosava', 'autosava', 'Auto plac Sava Sabac', '222333444');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `oglas`
--
ALTER TABLE `oglas`
  ADD CONSTRAINT `fk_prodavac_idProdavac` FOREIGN KEY (`idProdavac`) REFERENCES `prodavac` (`korisnickoime`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `ponuda`
--
ALTER TABLE `ponuda`
  ADD CONSTRAINT `fk_kupac_idKupac` FOREIGN KEY (`idKupac`) REFERENCES `kupac` (`korisnickoime`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_oglas_idOglas` FOREIGN KEY (`idOglas`) REFERENCES `oglas` (`idOg`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

/*!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 */;
