Last active
February 28, 2024 10:46
-
-
Save nasirdn/37a077c7eb121ed6e9d8aea098ab7b5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ----------------------------------------------------- | |
-- Table `ex2`.`orders` | |
-- ----------------------------------------------------- | |
CREATE TABLE IF NOT EXISTS `ex2`.`orders` ( | |
`id` INT NOT NULL AUTO_INCREMENT, | |
`shop_id` INT NOT NULL, | |
`product_id` INT NOT NULL, | |
`fio` INT NOT NULL, | |
`date` DATE NULL, | |
`quantity` TINYINT NULL, | |
`tel` VARCHAR(100) NULL, | |
`confirm` TINYINT NULL, | |
PRIMARY KEY (`id`, `shop_id`, `product_id`, `fio`), | |
UNIQUE INDEX `order_id_UNIQUE` (`id` ASC) VISIBLE, | |
INDEX `order_to_shop_idx` (`shop_id` ASC) VISIBLE, | |
INDEX `order_to_product_idx` (`product_id` ASC) VISIBLE, | |
INDEX `order_to_user_idx` (`fio` ASC) VISIBLE, | |
CONSTRAINT `order_to_shop` | |
FOREIGN KEY (`shop_id`) | |
REFERENCES `ex2`.`shops` (`id`) | |
ON DELETE CASCADE | |
ON UPDATE CASCADE, | |
CONSTRAINT `order_to_product` | |
FOREIGN KEY (`product_id`) | |
REFERENCES `ex2`.`products` (`id`) | |
ON DELETE CASCADE | |
ON UPDATE CASCADE, | |
CONSTRAINT `order_to_user` | |
FOREIGN KEY (`fio`) | |
REFERENCES `ex2`.`users` (`id`) | |
ON DELETE CASCADE | |
ON UPDATE CASCADE) | |
ENGINE = InnoDB; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
фрагмент запроса, касающийся создания и настройки таблицы Orders.
Лр2, бд, задание 2