Gaebobman / Face_Recognition

Face recognition for jetson Nano
0 stars 0 forks source link

DDL #1

Closed Gaebobman closed 1 year ago

Gaebobman commented 1 year ago
-- 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';
-------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `home_database` ;
USE `home_database` ;

-- -----------------------------------------------------
-- Table `home_database`.`visitor_info`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `home_database`.`visitor_info` (
  `user_id` VARCHAR(13) COLLATE 'utf8mb3_bin' NOT NULL,
  `enterance_time` TIMESTAMP NOT NULL,
  PRIMARY KEY (`user_id`, `enterance_time`))
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `home_database`.`water_usage`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `home_database`.`water_usage` (
  `usage_id` INT NOT NULL AUTO_INCREMENT,
  `user_id` VARCHAR(13) COLLATE 'utf8mb3_bin' NULL DEFAULT NULL,
  `START` TIMESTAMP NOT NULL,
  `END` TIMESTAMP NOT NULL,
  `PLACE` VARCHAR(45) COLLATE 'utf8mb3_bin' NOT NULL,
  `AMOUNT` FLOAT NOT NULL,
  PRIMARY KEY (`usage_id`),
  INDEX `fk_water_usage_user_id_idx` (`user_id` ASC) VISIBLE,
  CONSTRAINT `fk_water_usage_user_id`
    FOREIGN KEY (`user_id`)
    REFERENCES `home_database`.`visitor_info` (`user_id`))
ENGINE = InnoDB;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Gaebobman commented 1 year ago
CREATE TABLE IF NOT EXISTS `home_database`.`visitor_info` (
  `user_id` VARCHAR(13) COLLATE 'utf8mb3_bin' NOT NULL,
  `enterance_time` DATETIME NOT NULL,
  PRIMARY KEY (`user_id`, `enterance_time`))
ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `home_database`.`water_usage` (
  `usage_id` INT NOT NULL AUTO_INCREMENT,
  `user_id` VARCHAR(13) COLLATE 'utf8mb3_bin' NULL DEFAULT NULL,
  `START_TIME` DATETIME NOT NULL,
  `END_TIME` DATETIME NOT NULL,
  `PLACE` VARCHAR(45) COLLATE 'utf8mb3_bin' NOT NULL,
  `AMOUNT` FLOAT NOT NULL,
  PRIMARY KEY (`usage_id`),
  CONSTRAINT `fk_water_usage_user_id`
  FOREIGN KEY (`user_id`)
  REFERENCES `home_database`.`visitor_info` (`user_id`))
ENGINE = InnoDB;
Gaebobman commented 1 year ago

pymysql.err.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (home_database.water_usage, CONSTRAINT fk_water_usage_user_id FOREIGN KEY (user_id) REFERENCES visitor_info (user_id))')

Gaebobman commented 1 year ago

pymysql.err.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (home_database.water_usage, CONSTRAINT fk_water_usage_user_id FOREIGN KEY (user_id) REFERENCES visitor_info (user_id))')

해결완료, 테스트중 visitor_info가 비어있는 상태로 INSERT문을 실행해서 생긴 결과임