Skip to content
This repository has been archived by the owner on Nov 28, 2019. It is now read-only.

Commit

Permalink
Techdomotica.sql actualizada, ya funcional.
Browse files Browse the repository at this point in the history
  • Loading branch information
xman40100 authored Feb 26, 2019
1 parent 12869ab commit b4cdf20
Showing 1 changed file with 127 additions and 146 deletions.
273 changes: 127 additions & 146 deletions techdomotica.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- MySQL Script generated by MySQL Workbench
-- Sat Feb 23 19:00:09 2019
-- Mon Feb 25 22:14:14 2019
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering

Expand All @@ -8,211 +8,192 @@ SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema sistemadomotico
-- Schema techdomotica
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema sistemadomotico
-- Schema techdomotica
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `sistemadomotico` DEFAULT CHARACTER SET latin1 ;
USE `sistemadomotico` ;
CREATE SCHEMA IF NOT EXISTS `techdomotica` ;
USE `techdomotica` ;

-- -----------------------------------------------------
-- Table `sistemadomotico`.`administrador`
-- Table `techdomotica`.`menu`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`administrador` (
`idAdministrador` INT(11) NOT NULL,
`N_identificacion` INT(11) NULL DEFAULT NULL,
`Contraseña` NCHAR(32) NULL DEFAULT NULL,
PRIMARY KEY (`idAdministrador`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
CREATE TABLE IF NOT EXISTS `techdomotica`.`menu` (
`idmenu` INT NOT NULL,
`tipo` VARCHAR(45) NULL,
PRIMARY KEY (`idmenu`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`perfil`
-- Table `techdomotica`.`perfil`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`perfil` (
`idperfil` INT(11) NOT NULL,
`N_identificacion` INT(11) NULL DEFAULT NULL,
`Nom_perfil` VARCHAR(45) NULL DEFAULT NULL,
`Ape_perfil` VARCHAR(45) NULL DEFAULT NULL,
`Fecha` VARCHAR(45) NULL DEFAULT NULL,
`Dir_residencia` VARCHAR(45) NULL DEFAULT NULL,
`Sexo` VARCHAR(45) NULL DEFAULT NULL,
`menu_idMenu` INT(11) NOT NULL,
CREATE TABLE IF NOT EXISTS `techdomotica`.`perfil` (
`idperfil` INT NOT NULL,
`nom_perfil` VARCHAR(45) NULL,
`ape_perfil` VARCHAR(45) NULL,
`sexo` VARCHAR(45) NULL,
`menu_idmenu` INT NOT NULL,
PRIMARY KEY (`idperfil`),
INDEX `fk_perfil_menu1_idx` (`menu_idMenu` ASC),
INDEX `fk_perfil_menu1_idx` (`menu_idmenu` ASC),
CONSTRAINT `fk_perfil_menu1`
FOREIGN KEY (`menu_idMenu`)
REFERENCES `sistemadomotico`.`menu` (`idMenu`)
FOREIGN KEY (`menu_idmenu`)
REFERENCES `techdomotica`.`menu` (`idmenu`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`usuario`
-- Table `techdomotica`.`iniciar sesion`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`usuario` (
`idUsuario` INT(11) NOT NULL,
`Tipo_usuario` VARCHAR(45) NULL DEFAULT NULL,
`menu_idMenu` INT(11) NOT NULL,
`perfil_idperfil` INT(11) NOT NULL,
PRIMARY KEY (`idUsuario`),
INDEX `fk_usuario_menu1_idx` (`menu_idMenu` ASC),
INDEX `fk_usuario_perfil1_idx` (`perfil_idperfil` ASC),
CONSTRAINT `fk_usuario_menu1`
FOREIGN KEY (`menu_idMenu`)
REFERENCES `sistemadomotico`.`menu` (`idMenu`)
CREATE TABLE IF NOT EXISTS `techdomotica`.`iniciar sesion` (
`idiniciar sesion` INT NOT NULL AUTO_INCREMENT,
`clave` INT NULL,
`perfil_idperfil` INT NOT NULL,
`menu_idmenu` INT NOT NULL,
PRIMARY KEY (`idiniciar sesion`),
INDEX `fk_iniciar sesion_perfil_idx` (`perfil_idperfil` ASC),
INDEX `fk_iniciar sesion_menu1_idx` (`menu_idmenu` ASC),
CONSTRAINT `fk_iniciar sesion_perfil`
FOREIGN KEY (`perfil_idperfil`)
REFERENCES `techdomotica`.`perfil` (`idperfil`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_usuario_perfil1`
FOREIGN KEY (`perfil_idperfil`)
REFERENCES `sistemadomotico`.`perfil` (`idperfil`)
CONSTRAINT `fk_iniciar sesion_menu1`
FOREIGN KEY (`menu_idmenu`)
REFERENCES `techdomotica`.`menu` (`idmenu`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`iniciar sesion`
-- Table `techdomotica`.`dispositivo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`iniciar sesion` (
`idiniciar sesion` INT(11) NOT NULL AUTO_INCREMENT,
`N_identificacion` INT(11) NOT NULL,
`Contraseña` NCHAR(32) NOT NULL,
`administrador_idAdministrador` INT(11) NOT NULL,
`usuario_idUsuario` INT(11) NOT NULL,
PRIMARY KEY (`idiniciar sesion`),
INDEX `fk_iniciar sesion_administrador_idx` (`administrador_idAdministrador` ASC),
INDEX `fk_iniciar sesion_usuario1_idx` (`usuario_idUsuario` ASC),
CONSTRAINT `fk_iniciar sesion_administrador`
FOREIGN KEY (`administrador_idAdministrador`)
REFERENCES `sistemadomotico`.`administrador` (`idAdministrador`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_iniciar sesion_usuario1`
FOREIGN KEY (`usuario_idUsuario`)
REFERENCES `sistemadomotico`.`usuario` (`idUsuario`)
CREATE TABLE IF NOT EXISTS `techdomotica`.`dispositivo` (
`iddispositivo` INT NOT NULL AUTO_INCREMENT,
`nom_dispositivo` VARCHAR(45) NULL,
`direccion` VARCHAR(45) NULL,
`tipo` VARCHAR(45) NULL,
`estado` VARCHAR(45) NULL,
`condicion` VARCHAR(45) NULL,
`menu_idmenu` INT NOT NULL,
PRIMARY KEY (`iddispositivo`),
INDEX `fk_dispositivo_menu1_idx` (`menu_idmenu` ASC),
CONSTRAINT `fk_dispositivo_menu1`
FOREIGN KEY (`menu_idmenu`)
REFERENCES `techdomotica`.`menu` (`idmenu`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`menu`
-- Table `techdomotica`.`estados`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`menu` (
`idMenu` INT(11) NOT NULL AUTO_INCREMENT,
`iniciar sesion_idiniciar sesion` INT(11) NOT NULL,
PRIMARY KEY (`idMenu`),
INDEX `fk_menu_iniciar sesion1_idx` (`iniciar sesion_idiniciar sesion` ASC),
CONSTRAINT `fk_menu_iniciar sesion1`
FOREIGN KEY (`iniciar sesion_idiniciar sesion`)
REFERENCES `sistemadomotico`.`iniciar sesion` (`idiniciar sesion`)
CREATE TABLE IF NOT EXISTS `techdomotica`.`estados` (
`idestados` INT NOT NULL AUTO_INCREMENT,
`menu_idmenu` INT NOT NULL,
`dispositivo_iddispositivo` INT NOT NULL,
PRIMARY KEY (`idestados`),
INDEX `fk_estados_menu1_idx` (`menu_idmenu` ASC),
INDEX `fk_estados_dispositivo1_idx` (`dispositivo_iddispositivo` ASC),
CONSTRAINT `fk_estados_menu1`
FOREIGN KEY (`menu_idmenu`)
REFERENCES `techdomotica`.`menu` (`idmenu`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_estados_dispositivo1`
FOREIGN KEY (`dispositivo_iddispositivo`)
REFERENCES `techdomotica`.`dispositivo` (`iddispositivo`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`dispositivo`
-- Table `techdomotica`.`alarma`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`dispositivo` (
`idDispositivo` INT(11) NOT NULL,
`Nom_dispositivo` VARCHAR(45) NULL DEFAULT NULL,
`Direccion` VARCHAR(45) NULL DEFAULT NULL,
`Tipo` VARCHAR(45) NULL DEFAULT NULL,
`Estados` VARCHAR(45) NULL DEFAULT NULL,
`Condicion` VARCHAR(45) NULL DEFAULT NULL,
`menu_idMenu` INT(11) NOT NULL,
PRIMARY KEY (`idDispositivo`),
INDEX `fk_dispositivo_menu1_idx` (`menu_idMenu` ASC),
CONSTRAINT `fk_dispositivo_menu1`
FOREIGN KEY (`menu_idMenu`)
REFERENCES `sistemadomotico`.`menu` (`idMenu`)
CREATE TABLE IF NOT EXISTS `techdomotica`.`alarma` (
`idalarma` INT NOT NULL AUTO_INCREMENT,
`actuador` INT NULL,
`estados_idestados` INT NOT NULL,
`menu_idmenu` INT NOT NULL,
PRIMARY KEY (`idalarma`),
INDEX `fk_alarma_estados1_idx` (`estados_idestados` ASC),
INDEX `fk_alarma_menu1_idx` (`menu_idmenu` ASC),
CONSTRAINT `fk_alarma_estados1`
FOREIGN KEY (`estados_idestados`)
REFERENCES `techdomotica`.`estados` (`idestados`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_alarma_menu1`
FOREIGN KEY (`menu_idmenu`)
REFERENCES `techdomotica`.`menu` (`idmenu`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`estados`
-- Table `techdomotica`.`tipo_reporte`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`estados` (
`idEstados` INT(11) NOT NULL,
`menu_idMenu` INT(11) NOT NULL,
`dispositivo_idDispositivo` INT(11) NOT NULL,
PRIMARY KEY (`idEstados`),
INDEX `fk_estados_menu1_idx` (`menu_idMenu` ASC),
INDEX `fk_estados_dispositivo1_idx` (`dispositivo_idDispositivo` ASC),
CONSTRAINT `fk_estados_menu1`
FOREIGN KEY (`menu_idMenu`)
REFERENCES `sistemadomotico`.`menu` (`idMenu`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_estados_dispositivo1`
FOREIGN KEY (`dispositivo_idDispositivo`)
REFERENCES `sistemadomotico`.`dispositivo` (`idDispositivo`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
CREATE TABLE IF NOT EXISTS `techdomotica`.`tipo_reporte` (
`idtipo_reporte` INT NOT NULL,
`nombre` VARCHAR(45) NULL,
PRIMARY KEY (`idtipo_reporte`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`alarma`
-- Table `techdomotica`.`reporte`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`alarma` (
`idAlarma` INT(11) NOT NULL,
`Actuador` INT(11) NULL DEFAULT NULL,
`menu_idMenu` INT(11) NOT NULL,
`estados_idEstados` INT(11) NOT NULL,
PRIMARY KEY (`idAlarma`),
INDEX `fk_alarma_menu1_idx` (`menu_idMenu` ASC),
INDEX `fk_alarma_estados1_idx` (`estados_idEstados` ASC),
CONSTRAINT `fk_alarma_menu1`
FOREIGN KEY (`menu_idMenu`)
REFERENCES `sistemadomotico`.`menu` (`idMenu`)
CREATE TABLE IF NOT EXISTS `techdomotica`.`reporte` (
`idreporte` INT NOT NULL AUTO_INCREMENT,
`hora` TIMESTAMP NULL,
`fecha` DATETIME NULL,
`perfil_idperfil` INT NOT NULL,
`tipo_reporte_idtipo_reporte` INT NOT NULL,
PRIMARY KEY (`idreporte`),
INDEX `fk_reporte_perfil1_idx` (`perfil_idperfil` ASC),
INDEX `fk_reporte_tipo_reporte1_idx` (`tipo_reporte_idtipo_reporte` ASC),
CONSTRAINT `fk_reporte_perfil1`
FOREIGN KEY (`perfil_idperfil`)
REFERENCES `techdomotica`.`perfil` (`idperfil`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_alarma_estados1`
FOREIGN KEY (`estados_idEstados`)
REFERENCES `sistemadomotico`.`estados` (`idEstados`)
CONSTRAINT `fk_reporte_tipo_reporte1`
FOREIGN KEY (`tipo_reporte_idtipo_reporte`)
REFERENCES `techdomotica`.`tipo_reporte` (`idtipo_reporte`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadomotico`.`eventos`
-- Table `techdomotica`.`eventos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadomotico`.`eventos` (
`idEventos` INT(11) NOT NULL,
`Hora_entrada` DATE NULL DEFAULT NULL,
`Hora_salida` DATE NULL DEFAULT NULL,
`Dias_habiles` INT(11) NULL DEFAULT NULL,
`Eventoscol` VARCHAR(45) NULL DEFAULT NULL,
`menu_idMenu` INT(11) NOT NULL,
PRIMARY KEY (`idEventos`),
INDEX `fk_eventos_menu1_idx` (`menu_idMenu` ASC),
CREATE TABLE IF NOT EXISTS `techdomotica`.`eventos` (
`ideventos` INT NOT NULL AUTO_INCREMENT,
`menu_idmenu` INT NOT NULL,
`reporte_idreporte` INT NOT NULL,
PRIMARY KEY (`ideventos`),
INDEX `fk_eventos_menu1_idx` (`menu_idmenu` ASC),
INDEX `fk_eventos_reporte1_idx` (`reporte_idreporte` ASC),
CONSTRAINT `fk_eventos_menu1`
FOREIGN KEY (`menu_idMenu`)
REFERENCES `sistemadomotico`.`menu` (`idMenu`)
FOREIGN KEY (`menu_idmenu`)
REFERENCES `techdomotica`.`menu` (`idmenu`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_eventos_reporte1`
FOREIGN KEY (`reporte_idreporte`)
REFERENCES `techdomotica`.`reporte` (`idreporte`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
Expand Down

0 comments on commit b4cdf20

Please sign in to comment.