· 6 years ago · Aug 20, 2019, 02:56 AM
1CREATE DATABASE IF NOT EXISTS `mydb` /*!40100 DEFAULT CHARACTER SET utf8 */;
2USE `mydb`;
3-- MySQL dump 10.13 Distrib 8.0.17, for macos10.14 (x86_64)
4--
5-- Host: 127.0.0.1 Database: mydb
6-- ------------------------------------------------------
7-- Server version 5.7.26
8
9/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
10/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
11/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
12/*!50503 SET NAMES utf8 */;
13/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
14/*!40103 SET TIME_ZONE='+00:00' */;
15/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
16/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
17/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
18/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
19
20--
21-- Table structure for table `endereco`
22--
23
24DROP TABLE IF EXISTS `endereco`;
25/*!40101 SET @saved_cs_client = @@character_set_client */;
26/*!50503 SET character_set_client = utf8mb4 */;
27CREATE TABLE `endereco` (
28 `rua` varchar(30) NOT NULL,
29 `numero` varchar(6) NOT NULL,
30 `complemento` varchar(10) NOT NULL,
31 `cep` varchar(9) NOT NULL,
32 `bairro` varchar(45) NOT NULL,
33 `motorista_id` int(11) NOT NULL,
34 PRIMARY KEY (`rua`,`motorista_id`),
35 KEY `fk_Endereco_motorista_idx` (`motorista_id`),
36 CONSTRAINT `fk_Endereco_motorista` FOREIGN KEY (`motorista_id`) REFERENCES `motorista` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
37) ENGINE=InnoDB DEFAULT CHARSET=utf8;
38/*!40101 SET character_set_client = @saved_cs_client */;
39
40--
41-- Dumping data for table `endereco`
42--
43
44LOCK TABLES `endereco` WRITE;
45/*!40000 ALTER TABLE `endereco` DISABLE KEYS */;
46/*!40000 ALTER TABLE `endereco` ENABLE KEYS */;
47UNLOCK TABLES;
48
49--
50-- Table structure for table `fabricante_veiculos`
51--
52
53DROP TABLE IF EXISTS `fabricante_veiculos`;
54/*!40101 SET @saved_cs_client = @@character_set_client */;
55/*!50503 SET character_set_client = utf8mb4 */;
56CREATE TABLE `fabricante_veiculos` (
57 `id` int(11) NOT NULL AUTO_INCREMENT,
58 `nome` varchar(45) DEFAULT NULL,
59 PRIMARY KEY (`id`)
60) ENGINE=InnoDB DEFAULT CHARSET=utf8;
61/*!40101 SET character_set_client = @saved_cs_client */;
62
63--
64-- Dumping data for table `fabricante_veiculos`
65--
66
67LOCK TABLES `fabricante_veiculos` WRITE;
68/*!40000 ALTER TABLE `fabricante_veiculos` DISABLE KEYS */;
69/*!40000 ALTER TABLE `fabricante_veiculos` ENABLE KEYS */;
70UNLOCK TABLES;
71
72--
73-- Table structure for table `inspetor`
74--
75
76DROP TABLE IF EXISTS `inspetor`;
77/*!40101 SET @saved_cs_client = @@character_set_client */;
78/*!50503 SET character_set_client = utf8mb4 */;
79CREATE TABLE `inspetor` (
80 `id` int(11) NOT NULL,
81 `cargo` varchar(45) DEFAULT NULL,
82 `nome` varchar(55) DEFAULT NULL,
83 PRIMARY KEY (`id`)
84) ENGINE=InnoDB DEFAULT CHARSET=utf8;
85/*!40101 SET character_set_client = @saved_cs_client */;
86
87--
88-- Dumping data for table `inspetor`
89--
90
91LOCK TABLES `inspetor` WRITE;
92/*!40000 ALTER TABLE `inspetor` DISABLE KEYS */;
93/*!40000 ALTER TABLE `inspetor` ENABLE KEYS */;
94UNLOCK TABLES;
95
96--
97-- Table structure for table `jornada`
98--
99
100DROP TABLE IF EXISTS `jornada`;
101/*!40101 SET @saved_cs_client = @@character_set_client */;
102/*!50503 SET character_set_client = utf8mb4 */;
103CREATE TABLE `jornada` (
104 `id` int(11) NOT NULL AUTO_INCREMENT,
105 `valor` decimal(13,2) NOT NULL,
106 `inicio` datetime NOT NULL,
107 `fim` datetime DEFAULT NULL,
108 `distancia` int(4) DEFAULT NULL,
109 `motorista_id` int(11) NOT NULL,
110 `veiculo_placa` varchar(15) NOT NULL,
111 PRIMARY KEY (`id`),
112 KEY `fk_jornada_motorista1_idx` (`motorista_id`),
113 KEY `fk_jornada_veiculo1_idx` (`veiculo_placa`),
114 CONSTRAINT `fk_jornada_motorista1` FOREIGN KEY (`motorista_id`) REFERENCES `motorista` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
115 CONSTRAINT `fk_jornada_veiculo1` FOREIGN KEY (`veiculo_placa`) REFERENCES `veiculo` (`placa`) ON DELETE NO ACTION ON UPDATE NO ACTION
116) ENGINE=InnoDB DEFAULT CHARSET=utf8;
117/*!40101 SET character_set_client = @saved_cs_client */;
118
119--
120-- Dumping data for table `jornada`
121--
122
123LOCK TABLES `jornada` WRITE;
124/*!40000 ALTER TABLE `jornada` DISABLE KEYS */;
125/*!40000 ALTER TABLE `jornada` ENABLE KEYS */;
126UNLOCK TABLES;
127
128--
129-- Table structure for table `modelos`
130--
131
132DROP TABLE IF EXISTS `modelos`;
133/*!40101 SET @saved_cs_client = @@character_set_client */;
134/*!50503 SET character_set_client = utf8mb4 */;
135CREATE TABLE `modelos` (
136 `id` int(11) NOT NULL AUTO_INCREMENT,
137 `modelo` varchar(45) NOT NULL,
138 `ano` varchar(45) NOT NULL,
139 `cor` varchar(45) NOT NULL,
140 `fabricante_veiculos_id` int(11) NOT NULL,
141 PRIMARY KEY (`id`),
142 KEY `fk_modelos_veiculos_fabricante_veiculos1_idx` (`fabricante_veiculos_id`),
143 CONSTRAINT `fk_modelos_veiculos_fabricante_veiculos1` FOREIGN KEY (`fabricante_veiculos_id`) REFERENCES `fabricante_veiculos` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
144) ENGINE=InnoDB DEFAULT CHARSET=utf8;
145/*!40101 SET character_set_client = @saved_cs_client */;
146
147--
148-- Dumping data for table `modelos`
149--
150
151LOCK TABLES `modelos` WRITE;
152/*!40000 ALTER TABLE `modelos` DISABLE KEYS */;
153/*!40000 ALTER TABLE `modelos` ENABLE KEYS */;
154UNLOCK TABLES;
155
156--
157-- Table structure for table `motorista`
158--
159
160DROP TABLE IF EXISTS `motorista`;
161/*!40101 SET @saved_cs_client = @@character_set_client */;
162/*!50503 SET character_set_client = utf8mb4 */;
163CREATE TABLE `motorista` (
164 `id` int(11) NOT NULL,
165 `nome` varchar(55) NOT NULL,
166 `cnh` varchar(11) NOT NULL,
167 PRIMARY KEY (`id`)
168) ENGINE=InnoDB DEFAULT CHARSET=utf8;
169/*!40101 SET character_set_client = @saved_cs_client */;
170
171--
172-- Dumping data for table `motorista`
173--
174
175LOCK TABLES `motorista` WRITE;
176/*!40000 ALTER TABLE `motorista` DISABLE KEYS */;
177/*!40000 ALTER TABLE `motorista` ENABLE KEYS */;
178UNLOCK TABLES;
179
180--
181-- Table structure for table `passageiro`
182--
183
184DROP TABLE IF EXISTS `passageiro`;
185/*!40101 SET @saved_cs_client = @@character_set_client */;
186/*!50503 SET character_set_client = utf8mb4 */;
187CREATE TABLE `passageiro` (
188 `cpf` varchar(11) NOT NULL,
189 `nome` varchar(55) NOT NULL,
190 `idade` int(3) NOT NULL,
191 PRIMARY KEY (`cpf`)
192) ENGINE=InnoDB DEFAULT CHARSET=utf8;
193/*!40101 SET character_set_client = @saved_cs_client */;
194
195--
196-- Dumping data for table `passageiro`
197--
198
199LOCK TABLES `passageiro` WRITE;
200/*!40000 ALTER TABLE `passageiro` DISABLE KEYS */;
201INSERT INTO `passageiro` VALUES ('05165791424','arthur',20);
202/*!40000 ALTER TABLE `passageiro` ENABLE KEYS */;
203UNLOCK TABLES;
204
205--
206-- Table structure for table `pessoa_fisica`
207--
208
209DROP TABLE IF EXISTS `pessoa_fisica`;
210/*!40101 SET @saved_cs_client = @@character_set_client */;
211/*!50503 SET character_set_client = utf8mb4 */;
212CREATE TABLE `pessoa_fisica` (
213 `cpf` varchar(11) NOT NULL,
214 `motorista_id` int(11) NOT NULL,
215 PRIMARY KEY (`cpf`,`motorista_id`),
216 KEY `fk_pessoa_fisica_motorista1_idx` (`motorista_id`),
217 CONSTRAINT `fk_pessoa_fisica_motorista1` FOREIGN KEY (`motorista_id`) REFERENCES `motorista` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
218) ENGINE=InnoDB DEFAULT CHARSET=utf8;
219/*!40101 SET character_set_client = @saved_cs_client */;
220
221--
222-- Dumping data for table `pessoa_fisica`
223--
224
225LOCK TABLES `pessoa_fisica` WRITE;
226/*!40000 ALTER TABLE `pessoa_fisica` DISABLE KEYS */;
227/*!40000 ALTER TABLE `pessoa_fisica` ENABLE KEYS */;
228UNLOCK TABLES;
229
230--
231-- Table structure for table `pessoa_juridica`
232--
233
234DROP TABLE IF EXISTS `pessoa_juridica`;
235/*!40101 SET @saved_cs_client = @@character_set_client */;
236/*!50503 SET character_set_client = utf8mb4 */;
237CREATE TABLE `pessoa_juridica` (
238 `cnpj` varchar(18) NOT NULL,
239 `motorista_id` int(11) NOT NULL,
240 PRIMARY KEY (`cnpj`,`motorista_id`),
241 KEY `fk_pessoa_juridica_motorista1_idx` (`motorista_id`),
242 CONSTRAINT `fk_pessoa_juridica_motorista1` FOREIGN KEY (`motorista_id`) REFERENCES `motorista` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
243) ENGINE=InnoDB DEFAULT CHARSET=utf8;
244/*!40101 SET character_set_client = @saved_cs_client */;
245
246--
247-- Dumping data for table `pessoa_juridica`
248--
249
250LOCK TABLES `pessoa_juridica` WRITE;
251/*!40000 ALTER TABLE `pessoa_juridica` DISABLE KEYS */;
252/*!40000 ALTER TABLE `pessoa_juridica` ENABLE KEYS */;
253UNLOCK TABLES;
254
255--
256-- Table structure for table `reservas`
257--
258
259DROP TABLE IF EXISTS `reservas`;
260/*!40101 SET @saved_cs_client = @@character_set_client */;
261/*!50503 SET character_set_client = utf8mb4 */;
262CREATE TABLE `reservas` (
263 `id` int(11) NOT NULL AUTO_INCREMENT,
264 `veiculo_placa` varchar(15) NOT NULL,
265 `inicio` datetime DEFAULT NULL,
266 `fim` datetime DEFAULT NULL,
267 `passageiro_cpf` varchar(11) NOT NULL,
268 PRIMARY KEY (`id`),
269 KEY `fk_veiculo_has_passageiro_veiculo1_idx` (`veiculo_placa`),
270 KEY `fk_reservas_passageiro1_idx` (`passageiro_cpf`),
271 CONSTRAINT `fk_reservas_passageiro1` FOREIGN KEY (`passageiro_cpf`) REFERENCES `passageiro` (`cpf`) ON DELETE NO ACTION ON UPDATE NO ACTION,
272 CONSTRAINT `fk_veiculo_has_passageiro_veiculo1` FOREIGN KEY (`veiculo_placa`) REFERENCES `veiculo` (`placa`) ON DELETE NO ACTION ON UPDATE NO ACTION
273) ENGINE=InnoDB DEFAULT CHARSET=utf8;
274/*!40101 SET character_set_client = @saved_cs_client */;
275
276--
277-- Dumping data for table `reservas`
278--
279
280LOCK TABLES `reservas` WRITE;
281/*!40000 ALTER TABLE `reservas` DISABLE KEYS */;
282/*!40000 ALTER TABLE `reservas` ENABLE KEYS */;
283UNLOCK TABLES;
284
285--
286-- Table structure for table `veiculo`
287--
288
289DROP TABLE IF EXISTS `veiculo`;
290/*!40101 SET @saved_cs_client = @@character_set_client */;
291/*!50503 SET character_set_client = utf8mb4 */;
292CREATE TABLE `veiculo` (
293 `placa` varchar(15) NOT NULL,
294 `chassi` varchar(45) NOT NULL,
295 `data_inspecao` datetime DEFAULT NULL,
296 `modelos_id` int(11) NOT NULL,
297 `inspetor_id` int(11) NOT NULL,
298 PRIMARY KEY (`placa`),
299 KEY `fk_veiculo_modelos1_idx` (`modelos_id`),
300 KEY `fk_veiculo_inspetor1_idx` (`inspetor_id`),
301 CONSTRAINT `fk_veiculo_inspetor1` FOREIGN KEY (`inspetor_id`) REFERENCES `inspetor` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
302 CONSTRAINT `fk_veiculo_modelos1` FOREIGN KEY (`modelos_id`) REFERENCES `modelos` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
303) ENGINE=InnoDB DEFAULT CHARSET=utf8;
304/*!40101 SET character_set_client = @saved_cs_client */;
305
306--
307-- Dumping data for table `veiculo`
308--
309
310LOCK TABLES `veiculo` WRITE;
311/*!40000 ALTER TABLE `veiculo` DISABLE KEYS */;
312/*!40000 ALTER TABLE `veiculo` ENABLE KEYS */;
313UNLOCK TABLES;
314/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
315
316/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
317/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
318/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
319/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
320/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
321/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
322/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
323
324-- Dump completed on 2019-08-19 23:52:20