Código:
CREATE DATABASE IF NOT EXISTS serviciodegas; USE serviciodegas; -- -- Definition of table `clientes` -- DROP TABLE IF EXISTS `clientes`; CREATE TABLE `clientes` ( `id_cliente` int(11) NOT NULL AUTO_INCREMENT, `nombre` char(25) DEFAULT NULL, `direccion` varchar(25) DEFAULT NULL, `colonia` char(15) DEFAULT NULL, `idzona` int(11) DEFAULT NULL, PRIMARY KEY (`id_cliente`) ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1; -- -- Dumping data for table `clientes` -- /*!40000 ALTER TABLE `clientes` DISABLE KEYS */; INSERT INTO `clientes` (`id_cliente`,`nombre`,`direccion`,`colonia`,`idzona`) VALUES (2,'Margarita Ochoa','Azaleas No 1309','Campesina',105), (3,'Rosa Jaramillo','Antonio de Montes No 8093','San Felipe',104), (4,'Martin Cervantes','Mirador No 8456','Presidentes',104), (5,'Roberto Carrera','Siete Leguas No 6709','Villa Nueva',103), (6,'Marisa Ramirea','Pinabete No 1456','Granjas',103), (7,'Carmelo Lopez','Diaz Ordaz No 4380','Centro',101), (8,'Sofia Gaitan','Mina Loreto No 1410','El Mineral',107), (9,'Veronica Castro','Paraguay No 250','Panamericana',104), (12,'Laura ortiz','Villas No 89','Villa',102), (13,'Marisol Villegas','Desierto No 17','Sahuaros',102); /*!40000 ALTER TABLE `clientes` ENABLE KEYS */; -- -- Definition of table `consumo` -- DROP TABLE IF EXISTS `consumo`; CREATE TABLE `consumo` ( `idc` int(11) NOT NULL AUTO_INCREMENT, `Lectura` varchar(7) DEFAULT NULL, `id_m` int(11) DEFAULT NULL, `cobro` double DEFAULT NULL, `fecha_lectura` date DEFAULT NULL, `fecha_venc` date DEFAULT NULL, PRIMARY KEY (`idc`) ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1; -- -- Dumping data for table `consumo` -- /*!40000 ALTER TABLE `consumo` DISABLE KEYS */; INSERT INTO `consumo` (`idc`,`Lectura`,`id_m`,`cobro`,`fecha_lectura`,`fecha_venc`) VALUES (1,'89.4 M3',10201,182.899993896484,'2009-08-01','2009-08-08'), (2,'99.8 M3',10232,210.339996337891,'2009-08-01','2009-08-08'), (3,'120.9M3',10229,309.899993896484,'2009-08-02','2009-08-09'), (4,'98.24M3',10208,205.399993896484,'2009-08-02','2009-08-09'), (5,'150.9M3',10215,458.739990234375,'2009-08-03','2009-08-09'), (6,'110.8M3',10220,273.880004882813,'2009-08-03','2009-08-10'), (7,'99.7M3',10209,213.880004882813,'2009-08-03','2009-08-10'), (8,'169.0M3',10226,375.399993896484,'2009-08-04','2009-08-11'), (9,'133.5M3',10230,299.899993896484,'2009-08-04','2009-08-11'), (10,'80.30',10320,150.23,'2009-08-04','2009-08-11'); /*!40000 ALTER TABLE `consumo` ENABLE KEYS */; -- -- Definition of table `vendedores` -- DROP TABLE IF EXISTS `vendedores`; CREATE TABLE `vendedores` ( `id_vendedor` int(11) NOT NULL AUTO_INCREMENT, `nombre` char(25) DEFAULT NULL, `turno` varchar(8) DEFAULT NULL, PRIMARY KEY (`id_vendedor`) ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; -- -- Dumping data for table `vendedores` -- /*!40000 ALTER TABLE `vendedores` DISABLE KEYS */; INSERT INTO `vendedores` (`id_vendedor`,`nombre`,`turno`) VALUES (1,'Pedro Duarte','Matutino'), (2,'Leticia Vallejo','Matutino'), (3,'Gonzalo Guzman','Matutino'), (4,'Pedro Nevarez','Matutino'), (5,'Maria Gonzalez','Matutino'), (6,'Oralia Perez','Matutino'); /*!40000 ALTER TABLE `vendedores` ENABLE KEYS */; -- -- Definition of table `ventas` -- DROP TABLE IF EXISTS `ventas`; CREATE TABLE `ventas` ( `num_contrato` int(11) NOT NULL AUTO_INCREMENT, `id_vendedor` int(11) DEFAULT NULL, `tipo_de_contrato` char(15) DEFAULT NULL, `id_m` int(11) DEFAULT NULL, `id_cliente` int(11) DEFAULT NULL, PRIMARY KEY (`num_contrato`) ) ENGINE=InnoDB AUTO_INCREMENT=10021 DEFAULT CHARSET=latin1; -- -- Dumping data for table `ventas` -- /*!40000 ALTER TABLE `ventas` DISABLE KEYS */; INSERT INTO `ventas` (`num_contrato`,`id_vendedor`,`tipo_de_contrato`,`id_m`,`id_cliente`) VALUES (10010,2,'Contado',10215,8), (10011,5,'Contado',10201,4), (10012,1,'Arrendamiento',10232,2), (10013,6,'Contado',10229,9), (10014,3,'Arrendamiento',10208,5), (10015,5,'Arrendamiento',10220,7), (10016,2,'Contado',10209,6), (10017,1,'Arrendamiento',10226,1), (10019,6,'Contado',10230,3), (10020,2,'dddddd',1032,2); /*!40000 ALTER TABLE `ventas` ENABLE KEYS */; -- -- Definition of table `zonas` -- DROP TABLE IF EXISTS `zonas`; CREATE TABLE `zonas` ( `idzona` int(11) DEFAULT NULL, `colonia` char(15) DEFAULT NULL, `fecha_reparto` date DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `zonas` -- /*!40000 ALTER TABLE `zonas` DISABLE KEYS */; INSERT INTO `zonas` (`idzona`,`colonia`,`fecha_reparto`) VALUES (101,'Centro','2009-08-03'), (101,'Obrera','2009-08-03'), (102,'Rosario','2009-08-04'), (102,'Dale','2009-08-04'), (103,'Granjas','2009-08-05'), (103,'Villa Nueva','2009-08-05'), (104,'San Felipe','2009-08-06'), (104,'Presidentes','2009-08-06'), (104,'Panamericana','2009-08-06'), (105,'Campesina','2009-08-07'), (106,'Concordia','2009-08-08'), (107,'Mineral','2009-08-09'), (102,'Rosario','2009-08-04');