-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyData.sql
119 lines (102 loc) · 3.94 KB
/
myData.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
-- MySQL Script generated by MySQL Workbench
-- Thu Feb 3 15:30:56 2022
-- 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 ilovecraft
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema ilovecraft
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `ilovecraft` DEFAULT CHARACTER SET utf8 ;
-- -----------------------------------------------------
-- Schema new_schema1
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema new_schema1
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `new_schema1` ;
USE `ilovecraft` ;
-- -----------------------------------------------------
-- Table `ilovecraft`.`customers`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ilovecraft`.`customers` (
`id` INT NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(16) NOT NULL,
`last_name` VARCHAR(32) NOT NULL,
`email` VARCHAR(255) NULL,
`create_time` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`));
-- -----------------------------------------------------
-- Table `ilovecraft`.`categorys`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ilovecraft`.`categorys` (
`id` INT NOT NULL,
`category` VARCHAR(100) NOT NULL,
PRIMARY KEY (`id`));
-- -----------------------------------------------------
-- Table `ilovecraft`.`products`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ilovecraft`.`products` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`summary` VARCHAR(255) NULL,
`price` DECIMAL(10,2) NULL,
`discount` INT NULL,
`img` VARCHAR(510) NULL,
`quantity` INT NULL,
`category` VARCHAR(100) NULL,
PRIMARY KEY (`id`),
CONSTRAINT `category`
FOREIGN KEY ()
REFERENCES `ilovecraft`.`categorys` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `ilovecraft`.`order`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ilovecraft`.`order` (
`id` INT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`order_date` DATE NOT NULL,
`discount` DECIMAL(10,2) NULL,
`id_cli` INT NULL,
PRIMARY KEY (`id`),
INDEX `id_customer_idx` (`id_cli` ASC) VISIBLE,
CONSTRAINT `id_customer`
FOREIGN KEY (`id_cli`)
REFERENCES `ilovecraft`.`customers` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `ilovecraft`.`order_product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `ilovecraft`.`order_product` (
`order_id` INT NULL DEFAULT CURRENT_TIMESTAMP,
`product_id` INT NULL,
`quantity` INT NOT NULL,
INDEX `id_idx` (`product_id` ASC) VISIBLE,
INDEX `order_id_idx` (`order_id` ASC) VISIBLE,
CONSTRAINT `id_product`
FOREIGN KEY (`product_id`)
REFERENCES `ilovecraft`.`products` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `id_order`
FOREIGN KEY (`order_id`)
REFERENCES `ilovecraft`.`order` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
USE `new_schema1` ;
-- -----------------------------------------------------
-- Table `new_schema1`.`table1`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `new_schema1`.`table1` (
)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;