0119_ERD_ver2.PNG

E-R 다이어그램

0119pjt_erd_ver2.mwb

테이블 정보

SQL 쿼리문

-- MySQL Script generated by MySQL Workbench
-- Tue Jan 25 11:26:57 2022
-- 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 ssafy_dance
-- -----------------------------------------------------

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

-- -----------------------------------------------------
-- Table `ssafy_dance`.`users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`users` (
  `uid` INT NOT NULL AUTO_INCREMENT,
  `id` VARCHAR(45) NOT NULL,
  `password` VARCHAR(16) NOT NULL,
  `email` VARCHAR(30) NOT NULL,
  `name` VARCHAR(50) NOT NULL,
  `profile` VARCHAR(45) NULL,
  `date` DATETIME NULL,
  PRIMARY KEY (`uid`),
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
  UNIQUE INDEX `email_UNIQUE` (`email` ASC) VISIBLE,
  UNIQUE INDEX `name_UNIQUE` (`name` ASC) VISIBLE)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`videos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`videos` (
  `vid` INT NOT NULL AUTO_INCREMENT,
  `vuid` INT NOT NULL,
  `title` VARCHAR(45) NOT NULL,
  `like` INT NULL DEFAULT 0,
  `views` INT NULL DEFAULT 0,
  `url` VARCHAR(45) NOT NULL,
  `show` TINYINT(1) NULL DEFAULT 1,
  `kategori` INT NOT NULL,
  `thumbnail` VARCHAR(45) NULL,
  `date` DATETIME NULL,
  PRIMARY KEY (`vid`),
  INDEX `uid_idx` (`vuid` ASC) VISIBLE,
  CONSTRAINT `vuid`
    FOREIGN KEY (`vuid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`userlike`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`userlike` (
  `luid` INT NOT NULL,
  `lvid` INT NULL,
  `date` DATETIME NULL,
  INDEX `uid_idx` (`luid` ASC) VISIBLE,
  CONSTRAINT `lvid`
    FOREIGN KEY (`lvid`)
    REFERENCES `ssafy_dance`.`videos` (`vid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `luid`
    FOREIGN KEY (`luid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`comment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`comment` (
  `vcid` INT NOT NULL AUTO_INCREMENT,
  `cuid` INT NOT NULL,
  `cvid` INT NOT NULL,
  `content` VARCHAR(45) NOT NULL,
  `date` DATETIME NULL,
  PRIMARY KEY (`vcid`),
  INDEX `vid_idx` (`cvid` ASC) VISIBLE,
  INDEX `cuid_idx` (`cuid` ASC) VISIBLE,
  CONSTRAINT `cuid`
    FOREIGN KEY (`cuid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `cvid`
    FOREIGN KEY (`cvid`)
    REFERENCES `ssafy_dance`.`videos` (`vid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`subscribe`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`subscribe` (
  `subuid` INT NOT NULL,
  `subid` INT NULL,
  `date` DATETIME NULL,
  INDEX `uid_idx` (`subuid` ASC) VISIBLE,
  INDEX `subid_idx` (`subid` ASC) VISIBLE,
  CONSTRAINT `subuid`
    FOREIGN KEY (`subuid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `subid`
    FOREIGN KEY (`subid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`cupcomment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`cupcomment` (
  `cupid` INT NOT NULL AUTO_INCREMENT,
  `cupuid` INT NOT NULL,
  `cupvid` INT NOT NULL,
  `content` VARCHAR(45) NOT NULL,
  `date` DATETIME NULL,
  PRIMARY KEY (`cupid`),
  INDEX `uid_idx` (`cupuid` ASC) VISIBLE,
  INDEX `vid0_idx` (`cupvid` ASC) VISIBLE,
  CONSTRAINT `cupuip`
    FOREIGN KEY (`cupuid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `cupvid`
    FOREIGN KEY (`cupvid`)
    REFERENCES `ssafy_dance`.`videos` (`vid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`board`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`board` (
  `bid` INT NOT NULL,
  `category` INT NOT NULL,
  `buid` INT NOT NULL,
  `title` VARCHAR(45) NOT NULL,
  `content` VARCHAR(500) NOT NULL,
  `date` DATETIME NOT NULL,
  `url` VARCHAR(200) NULL,
  PRIMARY KEY (`bid`),
  INDEX `uid_idx` (`buid` ASC) VISIBLE,
  CONSTRAINT `buid`
    FOREIGN KEY (`buid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`boardcomment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`boardcomment` (
  `bcid` INT NOT NULL AUTO_INCREMENT,
  `bcuid` INT NOT NULL,
  `bbid` INT NOT NULL,
  `content` VARCHAR(200) NOT NULL,
  `date` DATETIME NULL,
  PRIMARY KEY (`bcid`),
  INDEX `uid_idx` (`bcuid` ASC) VISIBLE,
  INDEX `bid00_idx` (`bbid` ASC) VISIBLE,
  CONSTRAINT `bcuid`
    FOREIGN KEY (`bcuid`)
    REFERENCES `ssafy_dance`.`users` (`uid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `bbid`
    FOREIGN KEY (`bbid`)
    REFERENCES `ssafy_dance`.`board` (`bid`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `ssafy_dance`.`tag`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ssafy_dance`.`tag` (
  `tvid` INT NOT NULL,
  `tname` VARCHAR(45) NULL,
  INDEX `vid_idx` (`tvid` ASC) VISIBLE,
  CONSTRAINT `tvid`
    FOREIGN KEY (`tvid`)
    REFERENCES `ssafy_dance`.`videos` (`vid`)
    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;