Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Skema DB Untuk Obrolan?

Inilah cara mulai menggunakan MySQL Workbench

Ekspor PNG ERD

Dan skrip buat

SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @[email protected]@SQL_MODE, SQL_MODE='TRADITIONAL';

CREATE SCHEMA IF NOT EXISTS `chats` DEFAULT CHARACTER SET utf8 COLLATE default collation ;

-- -----------------------------------------------------
-- Table `chats`.`chat`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `chats`.`chat` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `chats`.`chat_user`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `chats`.`chat_user` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `handle` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `chats`.`chat_line`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `chats`.`chat_line` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `chat_id` INT UNSIGNED NOT NULL ,
  `user_id` INT UNSIGNED NOT NULL ,
  `line_text` TEXT NOT NULL ,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
  PRIMARY KEY (`id`) ,
  INDEX `fk_chat_line_chat` (`chat_id` ASC) ,
  INDEX `fk_chat_line_chat_user1` (`user_id` ASC) ,
  CONSTRAINT `fk_chat_line_chat`
    FOREIGN KEY (`chat_id` )
    REFERENCES `chats`.`chat` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_chat_line_chat_user1`
    FOREIGN KEY (`user_id` )
    REFERENCES `chats`.`chat_user` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;



SET [email protected]_SQL_MODE;
SET [email protected]_FOREIGN_KEY_CHECKS;
SET [email protected]_UNIQUE_CHECKS;

Dan Anda dipersilakan untuk mengunduh file MWB dari dropbox saya .



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. BIN() – Dapatkan Nilai Biner Angka di MySQL

  2. Alih-alih Pemicu di mysql

  3. Menggunakan Penasihat Pencadangan Basis Data untuk Mengotomatiskan Tugas Pemeliharaan

  4. Bagaimana cara membuat database localhost menggunakan mysql?

  5. Setel PDO untuk membuang pengecualian secara default