-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop.sql
169 lines (144 loc) · 5.41 KB
/
shop.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
-- MySQL Script generated by MySQL Workbench
-- Mon Sep 6 15:26:01 2021
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema shop
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema shop
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `shop` DEFAULT CHARACTER SET utf8 ;
-- -----------------------------------------------------
-- Schema shop
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema shop
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `shop` DEFAULT CHARACTER SET utf8 ;
USE `shop` ;
-- -----------------------------------------------------
-- Table `shop`.`admins`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`admins` (
`id` INT NOT NULL AUTO_INCREMENT,
`login` VARCHAR(70) NULL,
`password` VARCHAR(255) NULL,
`timestamp` DATE NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `shop`.`users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`users` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(70) NULL,
`email` VARCHAR(255) NULL,
`password` VARCHAR(255) NULL,
`timestamp` DATE NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `shop`.`products`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`products` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(70) NULL,
`slug` VARCHAR(250) NULL,
`subtitle` VARCHAR(255) NULL,
`description` LONGTEXT NULL,
`price` INT NULL,
`stock` INT NULL,
`rating` INT NULL,
`required_path_image` LONGTEXT NULL,
`timestamps` DATE NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `shop`.`categories`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`categories` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NULL,
`slug` VARCHAR(45) NULL,
`titmestamp` DATE NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `shop`.`coupons`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`coupons` (
`id` INT NOT NULL AUTO_INCREMENT,
`code` VARCHAR(45) NULL,
`reduce_percent` INT NULL,
`timestamp` DATE NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `shop`.`product_img`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`product_img` (
`id` INT NOT NULL AUTO_INCREMENT,
`image_path` LONGTEXT NULL,
`products_id` INT NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk_product_img_products1`
FOREIGN KEY (`products_id`)
REFERENCES `shop`.`products` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_product_img_products1_idx` ON `shop`.`product_img` (`products_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `shop`.`payments`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`payments` (
`id` INT NOT NULL AUTO_INCREMENT,
`shipping` LONGTEXT NULL,
`name` VARCHAR(70) NULL,
`lastname` VARCHAR(70) NULL,
`email` VARCHAR(200) NULL,
`country` VARCHAR(100) NULL,
`adress` VARCHAR(100) NULL,
`city` VARCHAR(100) NULL,
`state` VARCHAR(100) NULL,
`postal_code` VARCHAR(100) NULL,
`phone` VARCHAR(100) NULL,
`message` LONGTEXT NULL,
`timestamp` DATE NULL,
`users_id` INT NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk_payments_users1`
FOREIGN KEY (`users_id`)
REFERENCES `shop`.`users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_payments_users1_idx` ON `shop`.`payments` (`users_id` ASC) VISIBLE;
-- -----------------------------------------------------
-- Table `shop`.`categories_products`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shop`.`categories_products` (
`categories_id` INT NOT NULL,
`products_id` INT NOT NULL,
PRIMARY KEY (`categories_id`, `products_id`),
CONSTRAINT `fk_categories_has_products_categories1`
FOREIGN KEY (`categories_id`)
REFERENCES `shop`.`categories` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_categories_has_products_products1`
FOREIGN KEY (`products_id`)
REFERENCES `shop`.`products` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_categories_has_products_products1_idx` ON `shop`.`categories_products` (`products_id` ASC) VISIBLE;
CREATE INDEX `fk_categories_has_products_categories1_idx` ON `shop`.`categories_products` (`categories_id` ASC) VISIBLE;
USE `shop` ;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;