-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfowardModel2server.sql
More file actions
132 lines (114 loc) · 4.85 KB
/
Copy pathfowardModel2server.sql
File metadata and controls
132 lines (114 loc) · 4.85 KB
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
-- 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='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema myFridgeDB
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema myFridgeDB
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `myFridgeDB` DEFAULT CHARACTER SET utf8 ;
USE `myFridgeDB` ;
-- -----------------------------------------------------
-- Table `myFridgeDB`.`ingredients`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myFridgeDB`.`ingredients` (
`ingID` INT GENERATED ALWAYS AS () VIRTUAL,
`iname` VARCHAR(45) NULL,
`dateLogged` INT NULL,
`quantity` INT NULL,
`expDate` INT NULL,
PRIMARY KEY (`ingID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `myFridgeDB`.`icategory`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myFridgeDB`.`icategory` (
`icatID` INT GENERATED ALWAYS AS (0) VIRTUAL,
`icname` VARCHAR(45) NULL,
`desc` VARCHAR(45) NULL,
PRIMARY KEY (`icatID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `myFridgeDB`.`recipie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myFridgeDB`.`recipie` (
`desc` VARCHAR(200) NOT NULL,
`difficult` INT NULL,
`instructions` VARCHAR(200) NULL,
`recipieID` INT GENERATED ALWAYS AS (0) VIRTUAL,
PRIMARY KEY (`recipieID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `myFridgeDB`.`ingredients_has_recipie`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myFridgeDB`.`ingredients_has_recipie` (
`ingredients_ingID` INT NOT NULL,
`recipie_recipieID` INT NOT NULL,
PRIMARY KEY (`ingredients_ingID`, `recipie_recipieID`),
INDEX `fk_ingredients_has_recipie_recipie1_idx` (`recipie_recipieID` ASC),
INDEX `fk_ingredients_has_recipie_ingredients_idx` (`ingredients_ingID` ASC),
CONSTRAINT `fk_ingredients_has_recipie_ingredients`
FOREIGN KEY (`ingredients_ingID`)
REFERENCES `myFridgeDB`.`ingredients` (`ingID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_ingredients_has_recipie_recipie1`
FOREIGN KEY (`recipie_recipieID`)
REFERENCES `myFridgeDB`.`recipie` (`recipieID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `myFridgeDB`.`icategory_has_ingredients`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myFridgeDB`.`icategory_has_ingredients` (
`icategory_icatID` INT NOT NULL,
`ingredients_ingID` INT NOT NULL,
PRIMARY KEY (`icategory_icatID`, `ingredients_ingID`),
INDEX `fk_icategory_has_ingredients_ingredients1_idx` (`ingredients_ingID` ASC),
INDEX `fk_icategory_has_ingredients_icategory1_idx` (`icategory_icatID` ASC),
CONSTRAINT `fk_icategory_has_ingredients_icategory1`
FOREIGN KEY (`icategory_icatID`)
REFERENCES `myFridgeDB`.`icategory` (`icatID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_icategory_has_ingredients_ingredients1`
FOREIGN KEY (`ingredients_ingID`)
REFERENCES `myFridgeDB`.`ingredients` (`ingID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `myFridgeDB`.` rcategory`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myFridgeDB`.` rcategory` (
`rcatID` INT GENERATED ALWAYS AS (0) VIRTUAL,
`rcname` VARCHAR(45) NULL,
`desc` VARCHAR(45) NULL,
PRIMARY KEY (`rcatID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `myFridgeDB`.`recipie_has_ rcategory`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `myFridgeDB`.`recipie_has_ rcategory` (
`recipie_recipieID` INT NOT NULL,
` rcategory_rcatID` INT NOT NULL,
PRIMARY KEY (`recipie_recipieID`, ` rcategory_rcatID`),
INDEX `fk_recipie_has_ rcategory_ rcategory1_idx` (` rcategory_rcatID` ASC),
INDEX `fk_recipie_has_ rcategory_recipie1_idx` (`recipie_recipieID` ASC),
CONSTRAINT `fk_recipie_has_ rcategory_recipie1`
FOREIGN KEY (`recipie_recipieID`)
REFERENCES `myFridgeDB`.`recipie` (`recipieID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_recipie_has_ rcategory_ rcategory1`
FOREIGN KEY (` rcategory_rcatID`)
REFERENCES `myFridgeDB`.` rcategory` (`rcatID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;