You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
6.4 KiB
190 lines
6.4 KiB
-- MySQL Script generated by MySQL Workbench
|
|
-- Sat Apr 27 12:23:20 2024
|
|
-- Model: New Model Version: 1.0
|
|
-- MySQL Workbench Forward Engineering
|
|
|
|
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
|
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
|
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
|
|
|
|
-- -----------------------------------------------------
|
|
-- Schema inventarioalmacen
|
|
-- -----------------------------------------------------
|
|
|
|
-- -----------------------------------------------------
|
|
-- Schema inventarioalmacen
|
|
-- -----------------------------------------------------
|
|
CREATE SCHEMA IF NOT EXISTS `inventarioalmacen` DEFAULT CHARACTER SET utf8 ;
|
|
USE `inventarioalmacen` ;
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`marca`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`marca` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`nombre` VARCHAR(100) NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
PRIMARY KEY (`id`))
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`paises`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`paises` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`nombre` VARCHAR(100) NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
PRIMARY KEY (`id`))
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`estados`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`estados` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`nombre` VARCHAR(45) NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
`paises_id` INT NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
INDEX `fk_estados_paises1_idx` (`paises_id` ASC) VISIBLE,
|
|
CONSTRAINT `fk_estados_paises1`
|
|
FOREIGN KEY (`paises_id`)
|
|
REFERENCES `inventarioalmacen`.`paises` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION)
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`proveedor`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`proveedor` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`nombre` VARCHAR(100) NOT NULL,
|
|
`telefono` VARCHAR(10) NOT NULL,
|
|
`email` VARCHAR(100) NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
`domicilio` VARCHAR(100) NOT NULL,
|
|
`estados_id` INT NOT NULL,
|
|
`marca_id` INT NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
INDEX `fk_proveedor_estados1_idx` (`estados_id` ASC) VISIBLE,
|
|
INDEX `fk_proveedor_marca1_idx` (`marca_id` ASC) VISIBLE,
|
|
CONSTRAINT `fk_proveedor_estados1`
|
|
FOREIGN KEY (`estados_id`)
|
|
REFERENCES `inventarioalmacen`.`estados` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION,
|
|
CONSTRAINT `fk_proveedor_marca1`
|
|
FOREIGN KEY (`marca_id`)
|
|
REFERENCES `inventarioalmacen`.`marca` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION)
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`ubicacion`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`ubicacion` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`bloque` VARCHAR(1) NOT NULL,
|
|
`anaquel` INT NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
PRIMARY KEY (`id`))
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`tipo`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`tipo` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`tipo` VARCHAR(45) NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
PRIMARY KEY (`id`))
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`producto`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`producto` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`nombre` VARCHAR(100) NOT NULL,
|
|
`codigo` INT ZEROFILL NOT NULL,
|
|
`precio` FLOAT NOT NULL,
|
|
`piezas` INT NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
`fecha` DATE NOT NULL,
|
|
`proveedor_idproveedor` INT NOT NULL,
|
|
`ubicacion_id` INT NOT NULL,
|
|
`tipo_id` INT NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
INDEX `fk_producto_proveedor1_idx` (`proveedor_idproveedor` ASC) VISIBLE,
|
|
INDEX `fk_producto_ubicacion1_idx` (`ubicacion_id` ASC) VISIBLE,
|
|
INDEX `fk_producto_tipo1_idx` (`tipo_id` ASC) VISIBLE,
|
|
CONSTRAINT `fk_producto_proveedor1`
|
|
FOREIGN KEY (`proveedor_idproveedor`)
|
|
REFERENCES `inventarioalmacen`.`proveedor` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION,
|
|
CONSTRAINT `fk_producto_ubicacion1`
|
|
FOREIGN KEY (`ubicacion_id`)
|
|
REFERENCES `inventarioalmacen`.`ubicacion` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION,
|
|
CONSTRAINT `fk_producto_tipo1`
|
|
FOREIGN KEY (`tipo_id`)
|
|
REFERENCES `inventarioalmacen`.`tipo` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION)
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`roles`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`roles` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`rol` VARCHAR(45) NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
PRIMARY KEY (`id`))
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
-- -----------------------------------------------------
|
|
-- Table `inventarioalmacen`.`usuarios`
|
|
-- -----------------------------------------------------
|
|
CREATE TABLE IF NOT EXISTS `inventarioalmacen`.`usuarios` (
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
`nombre` VARCHAR(50) NOT NULL,
|
|
`apellidoPaterno` VARCHAR(50) NOT NULL,
|
|
`email` VARCHAR(100) NOT NULL,
|
|
`telefono` VARCHAR(10) NOT NULL,
|
|
`estado` INT NOT NULL,
|
|
`contrasenia` VARCHAR(20) NOT NULL,
|
|
`domicilio` VARCHAR(100) NOT NULL,
|
|
`estados_id` INT NOT NULL,
|
|
`roles_id` INT NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
INDEX `fk_usuarios_roles1_idx` (`roles_id` ASC) VISIBLE,
|
|
INDEX `fk_usuarios_estados1_idx` (`estados_id` ASC) VISIBLE,
|
|
CONSTRAINT `fk_usuarios_roles1`
|
|
FOREIGN KEY (`roles_id`)
|
|
REFERENCES `inventarioalmacen`.`roles` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION,
|
|
CONSTRAINT `fk_usuarios_estados1`
|
|
FOREIGN KEY (`estados_id`)
|
|
REFERENCES `inventarioalmacen`.`estados` (`id`)
|
|
ON DELETE NO ACTION
|
|
ON UPDATE NO ACTION)
|
|
ENGINE = InnoDB;
|
|
|
|
|
|
SET SQL_MODE=@OLD_SQL_MODE;
|
|
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
|
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
|
|