0% found this document useful (0 votes)
12 views4 pages

MySQL Workbench Forward Engineering Mydb

The document outlines the SQL commands for forward engineering a MySQL database schema named 'mydb'. It includes the creation of three tables: 'Student', 'Book', and 'Issue', with defined primary keys and foreign key constraints. Additionally, it sets and restores SQL modes and checks to ensure proper database integrity during the schema creation process.

Uploaded by

jeonirene9705
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

MySQL Workbench Forward Engineering Mydb

The document outlines the SQL commands for forward engineering a MySQL database schema named 'mydb'. It includes the creation of three tables: 'Student', 'Book', and 'Issue', with defined primary keys and foreign key constraints. Additionally, it sets and restores SQL modes and checks to ensure proper database integrity during the schema creation process.

Uploaded by

jeonirene9705
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

-- 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,ERRO
R_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------

-- Schema mydb

-- -----------------------------------------------------

-- -----------------------------------------------------

-- Schema mydb

-- -----------------------------------------------------

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

USE `mydb` ;

-- -----------------------------------------------------

-- Table `mydb`.`Student`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Student` (

` Student Id` INT NOT NULL,

`Student_Name` VARCHAR(45) NOT NULL,

`Department` VARCHAR(45) NOT NULL,

PRIMARY KEY (` Student Id`),


CONSTRAINT `Student Id`

FOREIGN KEY ()

REFERENCES `mydb`.`Student` ()

ON DELETE NO ACTION

ON UPDATE NO ACTION)

ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `mydb`.`Book`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Book` (

`Book Id` INT NOT NULL,

`Book_Name` VARCHAR(45) NOT NULL,

`Author` VARCHAR(45) NOT NULL,

PRIMARY KEY (`Book Id`))

ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `mydb`.`Issue`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Issue` (

`Issue_Id` INT NOT NULL,

`Issue_Date` VARCHAR(45) NOT NULL,


`Student_Id` INT NOT NULL,

`Book_Id` INT NOT NULL,

PRIMARY KEY (`Issue_Id`),

INDEX `Student Id_idx` (`Student_Id` ASC) VISIBLE,

INDEX `Book Id_idx` (`Book_Id` ASC) VISIBLE,

CONSTRAINT `Student Id`

FOREIGN KEY (`Student_Id`)

REFERENCES `mydb`.`Student` (` Student Id`)

ON DELETE NO ACTION

ON UPDATE NO ACTION,

CONSTRAINT `Book Id`

FOREIGN KEY (`Book_Id`)

REFERENCES `mydb`.`Book` (`Book Id`)

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;

You might also like