"CREATE TABLE `users`(
`user_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(100) NOT NULL,
`surname` VARCHAR(100) NOT NULL,
`email` VARCHAR(100) NOT NULL UNIQUE,
`phone` VARCHAR(25) NOT NULL UNIQUE,
`city` VARCHAR(100) NOT NULL,
`adress` VARCHAR(100) NOT NULL,
`password` VARCHAR(100) NOT NULL,
`date` DATETIME NOT NULL,
`role` ENUM('user', 'admin')
)"
"CREATE TABLE `cetegories`(
`category_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(20) NOT NULL UNIQUE,
`code` VARCHAR(20) NOT NULL UNIQUE,
`title` VARCHAR(150) NOT NULL
)"
"CREATE TABLE `products`(
`product_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`category_id` INT(11) NOT NULL,
`name` VARCHAR(50) NOT NULL,
`description` TEXT(4000) NOT NULL,
`title` VARCHAR(150) NOT NULL,
`price` DECIMAL(7,2) NOT NULL,
`image` VARCHAR(100) NOT NULL,
FOREIGN KEY (`category_id`) REFERENCES `cetegories`(`category_id`) ON DELETE SET NULL
)"
"CREATE TABLE `orders`(
`order_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` INT(11) NOT NULL,
`delivery` ENUM('Почта', 'Курьер', 'Служба доставки') NOT NULL,
`pay` ENUM('Наличные', 'Электронные деньги', 'Наложенный платеж') NOT NULL,
`total_sum` DECIMAL(7,2) NOT NULL,
`status` ENUM('В обработке', 'Отправлен', 'Получен') NOT NULL,
`date` DATETIME NOT NULL,
FOREIGN KEY(`user_id`) REFERENCES `users`(`user_id`)
)"
"CREATE TABLE `order_products`(
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`order_id` INT(11) NOT NULL,
`product_id` INT(11) NOT NULL,
`price` DECIMAL(7,2) NOT NULL,
FOREIGN KEY(`order_id`) REFERENCES `orders`(`order_id`),
FOREIGN KEY(`product_id`) REFERENCES `products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