Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE IF NOT EXISTS `mydb`.`orders` (
- `id` INT NOT NULL,
- `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 `id_UNIQUE` (`id` ASC) VISIBLE,
- INDEX `orders_to_products_idx` (`product_id` ASC) VISIBLE,
- INDEX `orders_to_users_idx` (`fio` ASC) VISIBLE,
- INDEX `orders_to_shops_idx` (`shop_id` ASC) VISIBLE,
- CONSTRAINT `orders_to_products`
- FOREIGN KEY (`product_id`)
- REFERENCES `mydb`.`products` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
- CONSTRAINT `orders_to_users`
- FOREIGN KEY (`fio`)
- REFERENCES `mydb`.`users` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION,
- CONSTRAINT `orders_to_shops`
- FOREIGN KEY (`shop_id`)
- REFERENCES `mydb`.`shops` (`id`)
- ON DELETE NO ACTION
- ON UPDATE NO ACTION)
- ENGINE = InnoDB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement