[go: up one dir, main page]

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

MySQL Workbench Forward Engineering Exp 1

The document outlines the process of forward engineering a MySQL database schema named 'mydb'. It includes the creation of three tables: 'Employee', 'Location', and 'Position', with specified columns and primary keys, as well as foreign key constraints for relationships between these tables. Additionally, it sets SQL modes and checks to ensure proper execution of the schema creation commands.

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)
7 views4 pages

MySQL Workbench Forward Engineering Exp 1

The document outlines the process of forward engineering a MySQL database schema named 'mydb'. It includes the creation of three tables: 'Employee', 'Location', and 'Position', with specified columns and primary keys, as well as foreign key constraints for relationships between these tables. Additionally, it sets SQL modes and checks to ensure proper execution of the schema creation commands.

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`.`Employee`

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

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

`Employee_Id` INT NOT NULL,

`Employee_Name` VARCHAR(45) NOT NULL,

`Salary` INT NOT NULL,

`Gender` VARCHAR(45) NOT NULL,


`Performance` VARCHAR(45) NOT NULL,

PRIMARY KEY (`Employee_Id`))

ENGINE = InnoDB;

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

-- Table `mydb`.`Location`

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

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

`Location_Id` INT NOT NULL,

`Citty` VARCHAR(45) NOT NULL,

`Address` VARCHAR(45) NOT NULL,

`Phone` INT NOT NULL,

`Pincode` INT NOT NULL,

PRIMARY KEY (`Location_Id`))

ENGINE = InnoDB;

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

-- Table `mydb`.`Position`

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

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

`Position_Id` INT NOT NULL,

`Education` VARCHAR(45) NOT NULL,

`Salary` INT NOT NULL,


`Title` VARCHAR(45) NOT NULL,

`Employee_Id` INT NOT NULL,

`Location_Id` INT NOT NULL,

PRIMARY KEY (`Position_Id`),

INDEX `Employee_Id_idx` (`Employee_Id` ASC) VISIBLE,

INDEX `Location_Id_idx` (`Location_Id` ASC) VISIBLE,

CONSTRAINT `Employee_Id`

FOREIGN KEY (`Employee_Id`)

REFERENCES `mydb`.`Employee` (`Employee_Id`)

ON DELETE NO ACTION

ON UPDATE NO ACTION,

CONSTRAINT `Location_Id`

FOREIGN KEY (`Location_Id`)

REFERENCES `mydb`.`Location` (`Location_Id`)

ON DELETE NO ACTION

ON UPDATE NO ACTION,

CONSTRAINT `Position_Id`

FOREIGN KEY (`Position_Id`)

REFERENCES `mydb`.`Position` (`Position_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