-- MySQL Script generated by MySQL Workbench
-- Mon May 12 19:53:24 2025
-- 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 mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema pozorisp3_denisov
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `pozorisp3_denisov` ;

-- -----------------------------------------------------
-- Schema pozorisp3_denisov
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `pozorisp3_denisov` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
USE `pozorisp3_denisov` ;

-- -----------------------------------------------------
-- Table `pozorisp3_denisov`.`warehouse`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pozorisp3_denisov`.`warehouse` ;

CREATE TABLE IF NOT EXISTS `pozorisp3_denisov`.`warehouse` (
  `postyplenie` INT NOT NULL AUTO_INCREMENT,
  `rezervirovanie` VARCHAR(45) NOT NULL,
  `spisanie` VARCHAR(45) NOT NULL,
  `postyplenie_i_rashod` VARCHAR(45) NOT NULL,
  `ostatki` VARCHAR(45) NOT NULL,
  `artikyl` VARCHAR(45) NOT NULL,
  `naznanie` VARCHAR(60) NOT NULL,
  `opisanie` VARCHAR(60) NOT NULL,
  `photo` BLOB NOT NULL,
  PRIMARY KEY (`postyplenie`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `pozorisp3_denisov`.`partners`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pozorisp3_denisov`.`partners` ;

CREATE TABLE IF NOT EXISTS `pozorisp3_denisov`.`partners` (
  `tip` INT NOT NULL AUTO_INCREMENT,
  `nazvanie_kompanii` VARCHAR(60) NOT NULL,
  `INN` INT NOT NULL,
  `phone_number` VARCHAR(45) NOT NULL,
  `email` VARCHAR(60) NOT NULL,
  `raiting` FLOAT NOT NULL,
  `istoriya_zakazov` VARCHAR(60) NOT NULL,
  `istoriya_postavok` VARCHAR(60) NOT NULL,
  PRIMARY KEY (`tip`),
  CONSTRAINT `tip`
    FOREIGN KEY (`tip`)
    REFERENCES `pozorisp3_denisov`.`warehouse` (`postyplenie`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `pozorisp3_denisov`.`services_and_parts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pozorisp3_denisov`.`services_and_parts` ;

CREATE TABLE IF NOT EXISTS `pozorisp3_denisov`.`services_and_parts` (
  `zadeystvovanie_sotrydniki` INT NOT NULL AUTO_INCREMENT,
  `min_chena` VARCHAR(45) NOT NULL,
  `vremya_vipolneniya` VARCHAR(45) NOT NULL,
  `sebestoimost` VARCHAR(45) NOT NULL,
  `nomer_boksa` VARCHAR(45) NOT NULL,
  `nyzhnie_materiali` VARCHAR(60) NOT NULL,
  PRIMARY KEY (`zadeystvovanie_sotrydniki`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `pozorisp3_denisov`.`managers_and_employees`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pozorisp3_denisov`.`managers_and_employees` ;

CREATE TABLE IF NOT EXISTS `pozorisp3_denisov`.`managers_and_employees` (
  `FIO` INT NOT NULL AUTO_INCREMENT,
  `dolzhnost` VARCHAR(45) NOT NULL,
  `poisk_partnerov` VARCHAR(45) NOT NULL,
  `raiting` FLOAT NOT NULL,
  `zayavki` VARCHAR(45) NOT NULL,
  `date_birthday` VARCHAR(45) NOT NULL,
  `staj` VARCHAR(45) NOT NULL,
  `med_spravka` VARCHAR(45) NOT NULL,
  `dopysk_k_rabote` VARCHAR(45) NOT NULL,
  `tasks` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`FIO`),
  CONSTRAINT `FIO`
    FOREIGN KEY (`FIO`)
    REFERENCES `pozorisp3_denisov`.`partners` (`tip`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FIO`
    FOREIGN KEY (`FIO`)
    REFERENCES `pozorisp3_denisov`.`services_and_parts` (`zadeystvovanie_sotrydniki`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `pozorisp3_denisov`.`dostup`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pozorisp3_denisov`.`dostup` ;

CREATE TABLE IF NOT EXISTS `pozorisp3_denisov`.`dostup` (
  `kolvo_rabochix_chasov` INT NOT NULL AUTO_INCREMENT,
  `vremya_vxoda` VARCHAR(45) NOT NULL,
  `vremya_vixoda` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`kolvo_rabochix_chasov`),
  CONSTRAINT `kolvo_rabochix_chasov`
    FOREIGN KEY (`kolvo_rabochix_chasov`)
    REFERENCES `pozorisp3_denisov`.`managers_and_employees` (`FIO`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `pozorisp3_denisov`.`parts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pozorisp3_denisov`.`parts` ;

CREATE TABLE IF NOT EXISTS `pozorisp3_denisov`.`parts` (
  `nazvanie` INT NOT NULL AUTO_INCREMENT,
  `tip` VARCHAR(45) NOT NULL,
  `postavschik` VARCHAR(45) NOT NULL,
  `ypakovka` VARCHAR(45) NOT NULL,
  `edinitsa_izmereniya` VARCHAR(45) NOT NULL,
  `price` VARCHAR(45) NOT NULL,
  `ostatok_na_sklade` VARCHAR(45) NOT NULL,
  `min_zapas` VARCHAR(45) NOT NULL,
  `istoriya_izmeneniy` VARCHAR(60) NOT NULL,
  PRIMARY KEY (`nazvanie`),
  CONSTRAINT `nazvanie`
    FOREIGN KEY (`nazvanie`)
    REFERENCES `pozorisp3_denisov`.`warehouse` (`postyplenie`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `pozorisp3_denisov`.`requests`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `pozorisp3_denisov`.`requests` ;

CREATE TABLE IF NOT EXISTS `pozorisp3_denisov`.`requests` (
  `klient` INT NOT NULL AUTO_INCREMENT,
  `istoriya_zakazov` VARCHAR(60) NOT NULL,
  `predlozhenie_sformirovano` VARCHAR(45) NOT NULL,
  `stoimost` VARCHAR(45) NOT NULL,
  `sroki` VARCHAR(45) NOT NULL,
  `status` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`klient`),
  CONSTRAINT `klient`
    FOREIGN KEY (`klient`)
    REFERENCES `pozorisp3_denisov`.`managers_and_employees` (`FIO`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
