Demo entry 4148658

SQL highlight

   

Submitted by anonymous on Mar 23, 2016 at 16:54
Language: SQL. Code size: 4.4 kB.

-- 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='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema register_db
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `register_db` ;

-- -----------------------------------------------------
-- Schema register_db
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `register_db` DEFAULT CHARACTER SET utf8 ;
USE `register_db` ;

-- -----------------------------------------------------
-- Table `register_db`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `register_db`.`user` (
  `id_user` BIGINT NOT NULL AUTO_INCREMENT,
  `first_name` VARCHAR(45) NULL,
  `last_name` VARCHAR(45) NULL,
  `email` VARCHAR(45) NULL,
  `password` VARCHAR(45) NULL,
  `phone` VARCHAR(15) NULL,
  `cell_phone` VARCHAR(15) NULL,
  `address` VARCHAR(45) NULL,
  `registration_date` BIGINT(12) NULL,
  PRIMARY KEY (`id_user`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `register_db`.`vehicle`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `register_db`.`vehicle` (
  `id_vehicle` BIGINT NOT NULL AUTO_INCREMENT,
  `model` VARCHAR(45) NULL,
  `number_plate` VARCHAR(10) NOT NULL,
  `color` VARCHAR(45) NULL,
  `imei` BIGINT NOT NULL,
  `registration_date` BIGINT(12) NULL,
  `id_user` BIGINT NOT NULL,
  PRIMARY KEY (`id_vehicle`),
  INDEX `fk_vehicle_user_idx` (`id_user` ASC),
  CONSTRAINT `fk_vehicle_user`
    FOREIGN KEY (`id_user`)
    REFERENCES `register_db`.`user` (`id_user`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `register_db`.`localization`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `register_db`.`localization` (
  `id_localization` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `event_command` VARCHAR(10) NULL,
  `info_position` INT NULL,
  `latitude` DECIMAL(10,6) NULL,
  `longitude` DECIMAL(10,6) NULL,
  `registration_date` BIGINT(12) NULL,
  `gps_status` VARCHAR(10) NULL,
  `number_satellites` INT NULL,
  `signal_quality` INT NULL,
  `speed` INT NULL,
  `altitude` INT NULL,
  `state` INT NULL,
  `id_vehicle` BIGINT NOT NULL,
  PRIMARY KEY (`id_localization`),
  INDEX `fk_localitation_vehicle1_idx` (`id_vehicle` ASC),
  CONSTRAINT `fk_localitation_vehicle1`
    FOREIGN KEY (`id_vehicle`)
    REFERENCES `register_db`.`vehicle` (`id_vehicle`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `register_db`.`configuration`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `register_db`.`configuration` (
  `id_configuration` BIGINT NOT NULL AUTO_INCREMENT,
  `interval` INT NULL,
  `amount` INT NULL,
  `heartbeat_interval` INT NULL,
  `id_vehicle` BIGINT NOT NULL,
  PRIMARY KEY (`id_configuration`),
  INDEX `fk_configuration_vehicle1_idx` (`id_vehicle` ASC),
  CONSTRAINT `fk_configuration_vehicle1`
    FOREIGN KEY (`id_vehicle`)
    REFERENCES `register_db`.`vehicle` (`id_vehicle`)
    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;

-- -----------------------------------------------------
-- Data for table `register_db`.`user`
-- -----------------------------------------------------
START TRANSACTION;
USE `register_db`;
INSERT INTO `register_db`.`user` (`id_user`, `first_name`, `last_name`, `email`, `password`, `phone`, `cell_phone`, `address`, `registration_date`) VALUES (1, 'Samuel', 'Tojino', 'samuel@gmail.com', '123', NULL, NULL, NULL, NULL);

COMMIT;


-- -----------------------------------------------------
-- Data for table `register_db`.`vehicle`
-- -----------------------------------------------------
START TRANSACTION;
USE `register_db`;
INSERT INTO `register_db`.`vehicle` (`id_vehicle`, `model`, `number_plate`, `color`, `imei`, `registration_date`, `id_user`) VALUES (1, 'Nissan', 'BAR-156', NULL, 353358017784062, 123456789, 1);

COMMIT;

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).