Created
February 26, 2024 17:28
-
-
Save nasirdn/c611062f97837c830a827d91c3f202ef to your computer and use it in GitHub Desktop.
Фрагмент запроса, касающийся создания и настройки таблицы invoice.
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 `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 `prod_idx` (`productid` ASC) VISIBLE, | |
CONSTRAINT `user` | |
FOREIGN KEY (`userid`) | |
REFERENCES `firstModel`.`user` (`id`) | |
ON DELETE CASCADE | |
ON UPDATE CASCADE, | |
CONSTRAINT `prod` | |
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Запрос к таблице invoice. ЛР №2. БД.