-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinit-script.sql
37 lines (33 loc) · 1.15 KB
/
init-script.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
DROP TABLE IF EXISTS `OrderData`;
DROP TABLE IF EXISTS `Customer`;
-- CREATE tables
CREATE TABLE `Customer` (
`customerId` VARCHAR(191) NOT NULL,
`name` VARCHAR(191) NOT NULL,
`email` VARCHAR(191) NOT NULL,
`phone` VARCHAR(191) NOT NULL,
PRIMARY KEY(`customerId`)
);
CREATE TABLE `OrderData` (
`orderId` VARCHAR(191) NOT NULL,
`price` DECIMAL(65,30) NOT NULL,
`customerCustomerId` VARCHAR(191) NOT NULL,
FOREIGN KEY(`customerCustomerId`) REFERENCES `Customer`(`customerId`),
PRIMARY KEY(`orderId`)
);
-- Insert data into the Customer table
INSERT INTO Customer (CustomerID, name, email, phone)
VALUES
("1", 'John Doe', '[email protected]', '123-456-7890'),
("2", 'Jane Smith', '[email protected]', '987-654-3210'),
("3", 'Alice Johnson', '[email protected]', '555-123-4567'),
("4", 'Bob Williams', '[email protected]', '888-555-9999'),
("5", 'Eva Brown', '[email protected]', '777-888-2222');
-- Insert data into the Order table
INSERT INTO OrderData (OrderID, price, customerCustomerId)
VALUES
("101", 100.50, "1"),
("102", 75.25, "5"),
("103", 200.00, "2"),
("104", 50.75, "4"),
("105", 300.90, "3");