fork download
  1. "CREATE TABLE `users`(
  2. `user_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  3. `name` VARCHAR(100) NOT NULL,
  4. `surname` VARCHAR(100) NOT NULL,
  5. `email` VARCHAR(100) NOT NULL UNIQUE,
  6. `phone` VARCHAR(25) NOT NULL UNIQUE,
  7. `city` VARCHAR(100) NOT NULL,
  8. `adress` VARCHAR(100) NOT NULL,
  9. `password` VARCHAR(100) NOT NULL,
  10. `date` DATETIME NOT NULL,
  11. `role` ENUM('user', 'admin')
  12. )"
  13.  
  14. "CREATE TABLE `cetegories`(
  15. `category_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  16. `name` VARCHAR(20) NOT NULL UNIQUE,
  17. `code` VARCHAR(20) NOT NULL UNIQUE,
  18. `title` VARCHAR(150) NOT NULL
  19. )"
  20.  
  21. "CREATE TABLE `products`(
  22. `product_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  23. `category_id` INT(11) NOT NULL,
  24. `name` VARCHAR(50) NOT NULL,
  25. `description` TEXT(4000) NOT NULL,
  26. `title` VARCHAR(150) NOT NULL,
  27. `price` DECIMAL(7,2) NOT NULL,
  28. `image` VARCHAR(100) NOT NULL,
  29. FOREIGN KEY (`category_id`) REFERENCES `cetegories`(`category_id`) ON DELETE SET NULL
  30. )"
  31.  
  32. "CREATE TABLE `orders`(
  33. `order_id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  34. `user_id` INT(11) NOT NULL,
  35. `delivery` ENUM('Почта', 'Курьер', 'Служба доставки') NOT NULL,
  36. `pay` ENUM('Наличные', 'Электронные деньги', 'Наложенный платеж') NOT NULL,
  37. `total_sum` DECIMAL(7,2) NOT NULL,
  38. `status` ENUM('В обработке', 'Отправлен', 'Получен') NOT NULL,
  39. `date` DATETIME NOT NULL,
  40. FOREIGN KEY(`user_id`) REFERENCES `users`(`user_id`)
  41. )"
  42.  
  43. "CREATE TABLE `order_products`(
  44. `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  45. `order_id` INT(11) NOT NULL,
  46. `product_id` INT(11) NOT NULL,
  47. `price` DECIMAL(7,2) NOT NULL,
  48. FOREIGN KEY(`order_id`) REFERENCES `orders`(`order_id`),
  49. FOREIGN KEY(`product_id`) REFERENCES `products`(`product_id`)
  50. )"
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty