Advertisement
Nikitalox

Запрос на создание таблицы orders. LR2

May 23rd, 2024 (edited)
1,212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.97 KB | None | 0 0
  1. CREATE TABLE IF NOT EXISTS `mydb`.`orders` (
  2.   `id` INT NOT NULL,
  3.   `shop_id` INT NOT NULL,
  4.   `product_id` INT NOT NULL,
  5.   `fio` INT NOT NULL,
  6.   `date` DATE NULL,
  7.   `quantity` TINYINT NULL,
  8.   `tel` VARCHAR(100) NULL,
  9.   `confirm` TINYINT NULL,
  10.   PRIMARY KEY (`id`, `shop_id`, `product_id`, `fio`),
  11.   UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
  12.   INDEX `orders_to_products_idx` (`product_id` ASC) VISIBLE,
  13.   INDEX `orders_to_users_idx` (`fio` ASC) VISIBLE,
  14.   INDEX `orders_to_shops_idx` (`shop_id` ASC) VISIBLE,
  15.   CONSTRAINT `orders_to_products`
  16.     FOREIGN KEY (`product_id`)
  17.     REFERENCES `mydb`.`products` (`id`)
  18.     ON DELETE NO ACTION
  19.     ON UPDATE NO ACTION,
  20.   CONSTRAINT `orders_to_users`
  21.     FOREIGN KEY (`fio`)
  22.     REFERENCES `mydb`.`users` (`id`)
  23.     ON DELETE NO ACTION
  24.     ON UPDATE NO ACTION,
  25.   CONSTRAINT `orders_to_shops`
  26.     FOREIGN KEY (`shop_id`)
  27.     REFERENCES `mydb`.`shops` (`id`)
  28.     ON DELETE NO ACTION
  29.     ON UPDATE NO ACTION)
  30. ENGINE = InnoDB
Tags: DB-LR2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement