-- MySQL dump 10.13  Distrib 8.0.17, for Win64 (x86_64)
--
-- Host: localhost    Database: kzp
-- ------------------------------------------------------
-- Server version	5.7.26

CREATE SCHEMA `kzp`;
USE kzp;

/*!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 */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `firma`
--

DROP TABLE IF EXISTS `firma`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `firma` (
  `IDFir` int(11) NOT NULL,
  `Naziv` char(20) NOT NULL,
  `Adresa` varchar(60) DEFAULT NULL,
  `Tel1` char(15) DEFAULT NULL,
  `Tel2` char(15) DEFAULT NULL,
  PRIMARY KEY (`IDFir`),
  UNIQUE KEY `Naziv` (`Naziv`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `firma`
--

LOCK TABLES `firma` WRITE;
/*!40000 ALTER TABLE `firma` DISABLE KEYS */;
INSERT INTO `firma` VALUES (0,'Petrolept','Beograd, Milana Rakica 5','011/258-221','063/223-223'),(1,'Radoje Dakic','Podgorica, Njegoseva 10/1','069/123-123',NULL),(2,'Tropik','Beograd, Dusana Vukasovica 50/1','011/123-1234','064/111-1111'),(3,'Meldovo','Beograd, Dusana Kovacevica 15/bb','064/222-3334',NULL);
/*!40000 ALTER TABLE `firma` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `kamion`
--

DROP TABLE IF EXISTS `kamion`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `kamion` (
  `IDKam` int(11) NOT NULL,
  `Marka` char(15) NOT NULL,
  `Nosivost` int(11) NOT NULL,
  `Godiste` int(11) DEFAULT NULL,
  `BrPopravljanja` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`IDKam`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `kamion`
--

LOCK TABLES `kamion` WRITE;
/*!40000 ALTER TABLE `kamion` DISABLE KEYS */;
INSERT INTO `kamion` VALUES (0,'Mercedes',4,1990,1),(1,'Mercedes',6,1994,0),(2,'Mercedes',5,2000,0),(3,'Mercedes',8,2001,0),(4,'Mercedes',15,2005,0),(5,'FAP',5,2002,0),(6,'FAP',3,2000,0),(7,'MAN',12,2004,0),(8,'MAN',10,1999,0),(9,'MAN',8,1997,2);
/*!40000 ALTER TABLE `kamion` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `mehanicar`
--

DROP TABLE IF EXISTS `mehanicar`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mehanicar` (
  `Specijalnost` char(15) DEFAULT NULL,
  `IDZap` int(11) NOT NULL,
  PRIMARY KEY (`IDZap`),
  CONSTRAINT `mehanicar_ibfk_1` FOREIGN KEY (`IDZap`) REFERENCES `zaposlen` (`IDZap`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `mehanicar`
--

LOCK TABLES `mehanicar` WRITE;
/*!40000 ALTER TABLE `mehanicar` DISABLE KEYS */;
INSERT INTO `mehanicar` VALUES ('Mercedes',4),('FAP',5),('MAN',6),('MAN',7);
/*!40000 ALTER TABLE `mehanicar` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `popravlja`
--

DROP TABLE IF EXISTS `popravlja`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `popravlja` (
  `Dana` int(11) DEFAULT NULL,
  `IDZap` int(11) NOT NULL,
  `IDKam` int(11) NOT NULL,
  PRIMARY KEY (`IDZap`,`IDKam`),
  KEY `IDKam` (`IDKam`),
  CONSTRAINT `popravlja_ibfk_1` FOREIGN KEY (`IDZap`) REFERENCES `mehanicar` (`IDZap`) ON DELETE NO ACTION,
  CONSTRAINT `popravlja_ibfk_2` FOREIGN KEY (`IDKam`) REFERENCES `kamion` (`IDKam`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `popravlja`
--

LOCK TABLES `popravlja` WRITE;
/*!40000 ALTER TABLE `popravlja` DISABLE KEYS */;
INSERT INTO `popravlja` VALUES (2,4,0),(3,6,9),(3,7,9);
/*!40000 ALTER TABLE `popravlja` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `posiljka`
--

DROP TABLE IF EXISTS `posiljka`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `posiljka` (
  `IDPos` int(11) NOT NULL,
  `Tezina` int(11) NOT NULL,
  `Vrednost` int(11) DEFAULT NULL,
  `MestoOd` char(25) DEFAULT NULL,
  `MestoDo` char(25) DEFAULT NULL,
  `IDFir` int(11) DEFAULT NULL,
  PRIMARY KEY (`IDPos`),
  KEY `IDFir` (`IDFir`),
  CONSTRAINT `posiljka_ibfk_1` FOREIGN KEY (`IDFir`) REFERENCES `firma` (`IDFir`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `posiljka`
--

LOCK TABLES `posiljka` WRITE;
/*!40000 ALTER TABLE `posiljka` DISABLE KEYS */;
INSERT INTO `posiljka` VALUES (0,1000,2000,'Kragujevac','Kraljevo',2),(1,500,10000,'Kragujevac','Kraljevo',1),(2,2500,25000,'Beograd','Berlin',0),(3,1000,8000,'Beograd','Sombor',0),(4,1900,4000,'Beograd','Sombor',2),(5,2800,12000,'Beograd','Subotica',3),(6,2750,8000,'Beograd','Arandjelovac',3),(7,2900,4500,'Beograd','Leskovac',2),(8,9000,11400,'Beograd','Niksic',0);
/*!40000 ALTER TABLE `posiljka` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `putovanje`
--

DROP TABLE IF EXISTS `putovanje`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `putovanje` (
  `IDPut` int(11) NOT NULL,
  `Status` char(1) DEFAULT NULL,
  `MestoOd` char(25) DEFAULT NULL,
  `MestoDo` char(25) DEFAULT NULL,
  `IDKam` int(11) DEFAULT NULL,
  `Duzina` int(11) DEFAULT NULL,
  PRIMARY KEY (`IDPut`),
  KEY `IDKam` (`IDKam`),
  CONSTRAINT `putovanje_ibfk_1` FOREIGN KEY (`IDKam`) REFERENCES `kamion` (`IDKam`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `putovanje`
--

LOCK TABLES `putovanje` WRITE;
/*!40000 ALTER TABLE `putovanje` DISABLE KEYS */;
INSERT INTO `putovanje` VALUES (0,'T','Beograd','Berlin',6,1500),(1,'O','Beograd','Sombor',1,190),(2,'P','Beograd','Subotica',7,240),(3,'O','Beograd','Arandjelovac',9,80),(4,'O','Beograd','Leskovac',5,300),(5,'O','Beograd','Niksic',4,460);
/*!40000 ALTER TABLE `putovanje` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `role`
--

DROP TABLE IF EXISTS `role`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role` varchar(45) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `role`
--

LOCK TABLES `role` WRITE;
/*!40000 ALTER TABLE `role` DISABLE KEYS */;
INSERT INTO `role` VALUES (1,'admin'),(2,'privileged'),(3,'unprivileged');
/*!40000 ALTER TABLE `role` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `seprevozi`
--

DROP TABLE IF EXISTS `seprevozi`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `seprevozi` (
  `IDPos` int(11) NOT NULL,
  `IDPut` int(11) NOT NULL,
  PRIMARY KEY (`IDPos`,`IDPut`),
  KEY `IDPut` (`IDPut`),
  CONSTRAINT `seprevozi_ibfk_1` FOREIGN KEY (`IDPos`) REFERENCES `posiljka` (`IDPos`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `seprevozi_ibfk_2` FOREIGN KEY (`IDPut`) REFERENCES `putovanje` (`IDPut`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `seprevozi`
--

LOCK TABLES `seprevozi` WRITE;
/*!40000 ALTER TABLE `seprevozi` DISABLE KEYS */;
INSERT INTO `seprevozi` VALUES (2,0),(3,1),(4,1),(5,2),(6,3),(7,4),(8,5);
/*!40000 ALTER TABLE `seprevozi` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `user`
--

DROP TABLE IF EXISTS `user`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(45) CHARACTER SET latin1 NOT NULL,
  `password` varchar(45) CHARACTER SET latin1 NOT NULL,
  `ime` varchar(45) DEFAULT NULL,
  `prezime` varchar(45) DEFAULT NULL,
  `slika` longblob,
  `idrole` int(11) NOT NULL,
  `vremekreiranja` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `datum_rodjenja` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `username_UNIQUE` (`username`),
  KEY `fk_role_idrole_idx` (`idrole`),
  CONSTRAINT `fk_role_idrole` FOREIGN KEY (`idrole`) REFERENCES `role` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `user`
--

LOCK TABLES `user` WRITE;
/*!40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (17,'pjitr','123','Петар','Ђорђевић',NULL,1,'2018-11-28 13:31:26','1993-04-09'),(20,'admin','123',NULL,NULL,NULL,1,'2018-11-28 13:33:25',NULL),(21,'mm','123','Marko','Markovic',NULL,2,'2018-11-28 13:35:46',NULL),(22,'jj','123','Jovan','Jovanovic',NULL,3,'2018-11-28 13:35:46',NULL);
/*!40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `vozac`
--

DROP TABLE IF EXISTS `vozac`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vozac` (
  `Kategorija` char(5) DEFAULT NULL,
  `IDZap` int(11) NOT NULL,
  PRIMARY KEY (`IDZap`),
  CONSTRAINT `vozac_ibfk_1` FOREIGN KEY (`IDZap`) REFERENCES `zaposlen` (`IDZap`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `vozac`
--

LOCK TABLES `vozac` WRITE;
/*!40000 ALTER TABLE `vozac` DISABLE KEYS */;
INSERT INTO `vozac` VALUES ('BCDE',0),('BC',1),('BC',2),('BCD',3);
/*!40000 ALTER TABLE `vozac` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `vozi`
--

DROP TABLE IF EXISTS `vozi`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vozi` (
  `IDZap` int(11) NOT NULL,
  `IDPut` int(11) NOT NULL,
  PRIMARY KEY (`IDZap`,`IDPut`),
  KEY `IDPut` (`IDPut`),
  CONSTRAINT `vozi_ibfk_1` FOREIGN KEY (`IDZap`) REFERENCES `vozac` (`IDZap`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `vozi_ibfk_2` FOREIGN KEY (`IDPut`) REFERENCES `putovanje` (`IDPut`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `vozi`
--

LOCK TABLES `vozi` WRITE;
/*!40000 ALTER TABLE `vozi` DISABLE KEYS */;
INSERT INTO `vozi` VALUES (2,0),(3,0),(3,1),(2,3),(0,4),(1,5),(3,5);
/*!40000 ALTER TABLE `vozi` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `zaposlen`
--

DROP TABLE IF EXISTS `zaposlen`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `zaposlen` (
  `IDZap` int(11) NOT NULL,
  `ImePrezime` char(40) NOT NULL,
  `Staz` int(11) DEFAULT NULL,
  PRIMARY KEY (`IDZap`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `zaposlen`
--

LOCK TABLES `zaposlen` WRITE;
/*!40000 ALTER TABLE `zaposlen` DISABLE KEYS */;
INSERT INTO `zaposlen` VALUES (0,'Marko Jagodic',12),(1,'Mihajlo Janjic',4),(2,'Dragan Milutinovic',6),(3,'Milos Miljkovic',7),(4,'Dusan Rajic',4),(5,'Marko Pesic',8),(6,'Obrad Zimonjic',7),(7,'Drasko Petkovic',8);
/*!40000 ALTER TABLE `zaposlen` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2020-04-23 17:44:13
