최종model.sql 4.96 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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
-- -----------------------------------------------------
-- Schema os_prj01
-- -----------------------------------------------------

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

-- -----------------------------------------------------
-- Table `mydb`.`calinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`calinfo` (
  `CalTotal` VARCHAR(45) NOT NULL,
  `UserNo` INT(11) NOT NULL,
  `ConsumeDate` DATETIME NOT NULL,
  `CalNo` INT(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`CalNo`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `mydb`.`consumeinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`consumeinfo` (
  `ConsumeNo` INT(11) NOT NULL,
  `ConsumeDetail` VARCHAR(45) NOT NULL,
  `ConsumeDate` DATETIME NOT NULL,
  `UserInfo_UserId` INT(11) NOT NULL,
  PRIMARY KEY (`ConsumeNo`),
  INDEX `fk_ConsumeInfo_UserInfo_idx` (`UserInfo_UserId` ASC) VISIBLE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `mydb`.`userinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`userinfo` (
  `UserNo` VARCHAR(45) NOT NULL,
  `UserID` VARCHAR(10) NOT NULL,
  `UserPW` VARCHAR(45) NOT NULL,
  `UserName` VARCHAR(45) NOT NULL,
  `UserHeight` INT(11) NOT NULL,
  `UserWeight` INT(11) NOT NULL,
  `UserGender` TINYINT(4) NOT NULL,
  `UserAge` INT(11) NOT NULL,
  PRIMARY KEY (`UserNo`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;

USE `os_prj01` ;

-- -----------------------------------------------------
-- Table `os_prj01`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`user` (
  `UserID` VARCHAR(20) NOT NULL,
  `UserPw` VARCHAR(45) NOT NULL,
  `UserNo` INT(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`UserNo`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `os_prj01`.`caltable`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`caltable` (
  `idCalTable` INT(11) NOT NULL AUTO_INCREMENT,
  `CalTotal` INT(11) NOT NULL,
  `CalLeftover` INT(11) NOT NULL,
  `CalUserNo` VARCHAR(45) NOT NULL,
  `user_UserNo` INT(11) NOT NULL,
  PRIMARY KEY (`idCalTable`, `user_UserNo`),
  INDEX `fk_caltable_user1_idx` (`user_UserNo` ASC) VISIBLE,
  CONSTRAINT `fk_caltable_user1`
    FOREIGN KEY (`user_UserNo`)
    REFERENCES `os_prj01`.`user` (`UserNo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 2
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `os_prj01`.`consume`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`consume` (
  `ConsumeNo` INT(11) NOT NULL AUTO_INCREMENT,
  `ConsumeDate` DATETIME NOT NULL,
  `ConsumeDetail` VARCHAR(45) NOT NULL,
  `user_UserNo` INT(11) NOT NULL,
  PRIMARY KEY (`ConsumeNo`),
  INDEX `fk_consume_user1_idx` (`user_UserNo` ASC) VISIBLE,
  CONSTRAINT `fk_consume_user1`
    FOREIGN KEY (`user_UserNo`)
    REFERENCES `os_prj01`.`user` (`UserNo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


-- -----------------------------------------------------
-- Table `os_prj01`.`userinfo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `os_prj01`.`userinfo` (
  `UserHeight` INT(11) NOT NULL,
  `UserWeight` INT(11) NOT NULL,
  `UserAge` INT(11) NOT NULL,
  `UserGender` TINYINT(4) NOT NULL,
  `user_UserNo` INT(11) NOT NULL,
  PRIMARY KEY (`user_UserNo`),
  INDEX `fk_userinfo_user_idx` (`user_UserNo` ASC) VISIBLE,
  CONSTRAINT `fk_userinfo_user`
    FOREIGN KEY (`user_UserNo`)
    REFERENCES `os_prj01`.`user` (`UserNo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;