Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MySQL Script generated by MySQL Workbench
- -- Wed May 15 11:50:11 2024
- -- 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 firstModel
- -- -----------------------------------------------------
- -- -----------------------------------------------------
- -- Schema firstModel
- -- -----------------------------------------------------
- CREATE SCHEMA IF NOT EXISTS `firstModel` DEFAULT CHARACTER SET utf8 ;
- USE `firstModel` ;
- -- -----------------------------------------------------
- -- Table `firstModel`.`user`
- -- -----------------------------------------------------
- CREATE TABLE IF NOT EXISTS `firstModel`.`user` (
- `id` INT NOT NULL AUTO_INCREMENT,
- `firstname` VARCHAR(45) NOT NULL,
- `secondname` VARCHAR(45) NOT NULL,
- PRIMARY KEY (`id`))
- ENGINE = InnoDB;
- -- -----------------------------------------------------
- -- Table `firstModel`.`product`
- -- -----------------------------------------------------
- CREATE TABLE IF NOT EXISTS `firstModel`.`product` (
- `idproduct` INT NOT NULL AUTO_INCREMENT,
- `title` VARCHAR(100) NOT NULL,
- `description` TEXT NULL,
- PRIMARY KEY (`idproduct`))
- ENGINE = InnoDB;
- -- -----------------------------------------------------
- -- Table `firstModel`.`invoice`
- -- -----------------------------------------------------
- CREATE TABLE IF NOT EXISTS `firstModel`.`invoice` (
- `idinvoice` INT NOT NULL AUTO_INCREMENT,
- `userid` INT NOT NULL,
- `productid` INT NOT NULL,
- `cost` DECIMAL(10,2) NOT NULL,
- PRIMARY KEY (`idinvoice`),
- INDEX `user_idx` (`userid` ASC) VISIBLE,
- INDEX `product_idx` (`productid` ASC) VISIBLE,
- CONSTRAINT `user`
- FOREIGN KEY (`userid`)
- REFERENCES `firstModel`.`user` (`id`)
- ON DELETE CASCADE
- ON UPDATE CASCADE,
- CONSTRAINT `product`
- FOREIGN KEY (`productid`)
- REFERENCES `firstModel`.`product` (`idproduct`)
- ON DELETE CASCADE
- ON UPDATE CASCADE)
- ENGINE = InnoDB;
- SET SQL_MODE=@OLD_SQL_MODE;
- SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
- SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement