-
Notifications
You must be signed in to change notification settings - Fork 0
/
LittleLemonDB.txt
124 lines (108 loc) · 4.52 KB
/
LittleLemonDB.txt
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
-- 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 LittleLemonDB
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema LittleLemonDB
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `LittleLemonDB` DEFAULT CHARACTER SET utf8 ;
USE `LittleLemonDB` ;
-- -----------------------------------------------------
-- Table `LittleLemonDB`.`Booking`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `LittleLemonDB`.`Booking` (
`BookingID` INT NOT NULL,
`Date` DATETIME NOT NULL,
`TableNumber` INT NOT NULL,
PRIMARY KEY (`BookingID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `LittleLemonDB`.`Customer`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `LittleLemonDB`.`Customer` (
`CustomerID` INT NOT NULL,
`FullName` VARCHAR(255) NOT NULL,
`ContactNumber` VARCHAR(45) NOT NULL,
`Email` VARCHAR(255) NOT NULL,
PRIMARY KEY (`CustomerID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `LittleLemonDB`.`Menu`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `LittleLemonDB`.`Menu` (
`MenuID` INT NOT NULL,
`Name` VARCHAR(45) NULL,
`Description` VARCHAR(255) NULL,
PRIMARY KEY (`MenuID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `LittleLemonDB`.`DeliveryStatus`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `LittleLemonDB`.`DeliveryStatus` (
`DeliveryID` INT NOT NULL,
`DeliveryDate` DATETIME NOT NULL,
PRIMARY KEY (`DeliveryID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `LittleLemonDB`.`Orders`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `LittleLemonDB`.`Orders` (
`OrderID` INT NOT NULL,
`Date` DATETIME NOT NULL,
`Quantity` INT NOT NULL,
`TotalCost` DECIMAL NULL,
`Booking_BookingID` INT NOT NULL,
`Customer_CustomerID` INT NOT NULL,
`Menu_MenuID` INT NOT NULL,
`DeliveryStatus_DeliveryID` INT NOT NULL,
PRIMARY KEY (`OrderID`, `Customer_CustomerID`, `Menu_MenuID`, `DeliveryStatus_DeliveryID`),
INDEX `fk_Orders_Booking_idx` (`Booking_BookingID` ASC) VISIBLE,
INDEX `fk_Orders_Customer1_idx` (`Customer_CustomerID` ASC) VISIBLE,
INDEX `fk_Orders_Menu1_idx` (`Menu_MenuID` ASC) VISIBLE,
INDEX `fk_Orders_DeliveryStatus1_idx` (`DeliveryStatus_DeliveryID` ASC) VISIBLE,
CONSTRAINT `fk_Orders_Booking`
FOREIGN KEY (`Booking_BookingID`)
REFERENCES `LittleLemonDB`.`Booking` (`BookingID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Orders_Customer1`
FOREIGN KEY (`Customer_CustomerID`)
REFERENCES `LittleLemonDB`.`Customer` (`CustomerID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Orders_Menu1`
FOREIGN KEY (`Menu_MenuID`)
REFERENCES `LittleLemonDB`.`Menu` (`MenuID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Orders_DeliveryStatus1`
FOREIGN KEY (`DeliveryStatus_DeliveryID`)
REFERENCES `LittleLemonDB`.`DeliveryStatus` (`DeliveryID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `LittleLemonDB`.`Staff`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `LittleLemonDB`.`Staff` (
`StaffID` INT NOT NULL,
`FullName` VARCHAR(255) NOT NULL,
`ContactNumber` VARCHAR(45) NOT NULL,
`Email` VARCHAR(255) NOT NULL,
`Role` VARCHAR(45) NOT NULL,
`Salary` DECIMAL NOT NULL,
`Customer_CustomerID` INT NOT NULL,
PRIMARY KEY (`StaffID`),
INDEX `fk_Staff_Customer1_idx` (`Customer_CustomerID` ASC) VISIBLE,
CONSTRAINT `fk_Staff_Customer1`
FOREIGN KEY (`Customer_CustomerID`)
REFERENCES `LittleLemonDB`.`Customer` (`CustomerID`)
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;