· 6 years ago · Mar 23, 2020, 11:04 AM
1CREATE SCHEMA IF NOT EXISTS `ferretería` DEFAULT CHARACTER SET utf8 ;
2USE `ferretería` ;
3CREATE TABLE IF NOT EXISTS `ferretería`.`clientes` (
4 `idclientes` INT NOT NULL AUTO_INCREMENT,
5 `Nombre` VARCHAR(15) NOT NULL,
6 `Apellidos` VARCHAR(30) NOT NULL,
7 `Teléfono` CHAR(9) NOT NULL,
8 `Direccion` VARCHAR(45) NOT NULL,
9 `Ciudad` VARCHAR(15) NOT NULL,
10 `Email` VARCHAR(45) NOT NULL,
11 PRIMARY KEY (`idclientes`))
12ENGINE = InnoDB;
13CREATE TABLE IF NOT EXISTS `ferretería`.`productos` (
14 `id_producto` INT UNSIGNED NOT NULL AUTO_INCREMENT,
15 `Tipo_producto` VARCHAR(15) NOT NULL,
16 `fecha_almacenamiento` DATE NOT NULL,
17 `fecha_fabricacion` DATE NOT NULL,
18 PRIMARY KEY (`id_producto`))
19ENGINE = InnoDB;
20CREATE TABLE IF NOT EXISTS `ferretería`.`ventas` (
21 `idventa` INT NOT NULL AUTO_INCREMENT,
22 `fecha_venta` DATE NULL,
23 `idclientes` INT NULL,
24 `idproducto` INT UNSIGNED NOT NULL,
25 PRIMARY KEY (`idventa`),
26 INDEX `fkidproductos_idx` (`idproducto` ASC) VISIBLE,
27 INDEX `fkidclientes_idx` (`idclientes` ASC) VISIBLE,
28 CONSTRAINT `fkidproductos`
29 FOREIGN KEY (`idproducto`)
30 REFERENCES `ferretería`.`productos` (`id_producto`)
31 ON DELETE NO ACTION
32 ON UPDATE NO ACTION,
33 CONSTRAINT `fkidclientes`
34 FOREIGN KEY (`idclientes`)
35 REFERENCES `ferretería`.`clientes` (`idclientes`)
36 ON DELETE NO ACTION
37 ON UPDATE NO ACTION)
38ENGINE = InnoDB;
39
40
41SET SQL_MODE=@OLD_SQL_MODE;
42SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
43SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
44
45
46INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('001', 'Jose_Antonio', 'Perez', '666666661', 'Calle_Tuy', 'Lugo', 'je@gmail.com');
47INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('002', 'Julian', 'Gonzalez', '666666662', 'Calle_fe', 'Lugo', 'jr@gmail.com');
48INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('003', 'Mariam', 'Lopez', '666666663', 'Calle_ramon', 'Coruña', 'jy@homtail.com');
49INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('004', 'Jose_Luis', 'Vazquez', '666666664', 'Calle_rodriman', 'Pontevedra', 'ju@gmail.com');
50INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('005', 'Silvia', 'Otero', '666666665', 'Calle_castelao', 'Lugo', 'sdf@gmail.com');
51INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('006', 'Maria', 'Sanchez', '666666666', 'Calle-fontilas', 'Coruña', 'asfg@gmail.com');
52INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('007', 'Jose', 'Losada', '666666667', 'Calle_kilo', 'Lugo', 'sfdg@gmail.com');
53INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('008', 'Mariano', 'Rajoi', '666666668', 'Calle_princesa', 'Lugo', 'dfh@gmail.com');
54INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('009', 'Zapatero', ' Lopez', '666666669', 'Calle_san', 'Lugo', 'ghj@gmail.com');
55INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('010', 'Pedro', 'Sanchez', '666666660', 'Calle_pepe', 'Coruña', 'fg3@gmail.com');
56INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('011', 'Pabli', 'Motos', '666666611', 'Calle_rosa', 'Lugo', 'dfb@gmail.com');
57INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('012', 'Cielo', 'Azul', '666666612', 'Calle_ke', 'Lugo', 'dcv@hotmail.com');
58INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('013', 'Lucero', 'Costanza', '666666613', 'Calle_Peraxz', 'Pontevedra', 'sd@hotmail.com');
59INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('014', 'Rosario', 'Sanchez', '666666614', 'Calle_Presi', 'Lugo', 'bbb@gmail.com');
60INSERT INTO `ferretería`.`clientes` (`idclientes`, `Nombre`, `Apellidos`, `Teléfono`, `Direccion`, `Ciudad`, `Email`) VALUES ('015', 'JOse_Luis', 'Sanchez', '666666615', 'Calle_Anto', 'Lugo', 'ccc4@gmail.com');
61
62INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('001', 'Herramienta', '2020-03-01', '2012-01-04');
63INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('002', 'Cable', '2020-03-01', '2013-01-04');
64INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('003', 'Candado', '2020-03-01', '2015-01-04');
65INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('004', 'Llaves', '2020-03-01', '2016-01-04');
66INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('005', 'Herramienta', '2020-03-01', '2012-01-04');
67INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('006', 'Manguera', '2020-03-01', '2015-01-04');
68INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('007', 'Cable', '2020-03-01', '2016-01-04');
69INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('008', 'Llaves', '2020-03-01', '2016-01-04');
70INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('009', 'Herramienta', '2020-03-01', '2016-01-04');
71INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('010', 'Candado', '2020-03-01', '2012-01-04');
72INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('011', 'Cable', '2020-03-01', '2011-01-04');
73INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('012', 'Llaves', '2020-03-01', '2010-01-04');
74INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('013', 'Herramienta', '2020-03-01', '2018-01-04');
75INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('014', 'Candado', '2020-03-01', '2019-01-04');
76INSERT INTO `ferretería`.`productos` (`id_producto`, `Tipo_producto`, `fecha_almacenamiento`, `fecha_fabricacion`) VALUES ('015', 'Cable', '2020-03-01', '2019-01-04');
77
78INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('001', '2020-03-01', '003', '008');
79INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('002', '2020-03-01', '008', '005');
80INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('003', '2020-03-01', '005', '001');
81INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('004', '2020-03-01', '009', '011');
82INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('005', '2020-03-01', '004', '015');
83INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('006', '2020-03-01', '001', '012');
84INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('007', '2020-03-01', '006', '014');
85INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('008', '2020-03-01', '010', '002');
86INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('009', '2020-03-01', '005', '003');
87INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('010', '2020-03-01', '014', '007');
88INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('011', '2020-03-01', '009', '004');
89INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('012', '2020-03-01', '011', '006');
90INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('013', '2020-03-01', '002', '009');
91INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('014', '2020-03-01', '014', '010');
92INSERT INTO `ferretería`.`ventas` (`idventa`, `fecha_venta`, `idclientes`, `idproducto`) VALUES ('015', '2020-03-01', '005', '013');