-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.sql
59 lines (59 loc) · 3.67 KB
/
database.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
SET DB_CLOSE_DELAY -1;
;
CREATE USER IF NOT EXISTS SA SALT 'ed67a8002d9b9493' HASH '2ee29f66ef17df9f3d90c1143f1131326d6578a1009d6c817bf841b451b20daf' ADMIN;
CREATE SEQUENCE PUBLIC.SYSTEM_SEQUENCE_15FFA372_F73F_4953_BA6C_F2B82D5B0073 START WITH 3 BELONGS_TO_TABLE;
CREATE SEQUENCE PUBLIC.SYSTEM_SEQUENCE_151A446D_398B_4796_91C9_C40B2FF2481F START WITH 1 BELONGS_TO_TABLE;
CREATE SEQUENCE PUBLIC.SYSTEM_SEQUENCE_8F149D1C_F851_4266_B1D7_FE96DB954A8D START WITH 3 BELONGS_TO_TABLE;
CREATE SEQUENCE PUBLIC.SYSTEM_SEQUENCE_4588CEFE_3044_4D32_97C4_C1C11E955B18 START WITH 5 BELONGS_TO_TABLE;
CREATE MEMORY TABLE PUBLIC.APP_USER(
ID BIGINT DEFAULT (NEXT VALUE FOR PUBLIC.SYSTEM_SEQUENCE_151A446D_398B_4796_91C9_C40B2FF2481F) NOT NULL NULL_TO_DEFAULT SEQUENCE PUBLIC.SYSTEM_SEQUENCE_151A446D_398B_4796_91C9_C40B2FF2481F,
PASSWORD VARCHAR(255),
ROLES VARCHAR(255),
SCREEN_NAME VARCHAR(255)
);
ALTER TABLE PUBLIC.APP_USER ADD CONSTRAINT PUBLIC.CONSTRAINT_7 PRIMARY KEY(ID);
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.APP_USER;
CREATE MEMORY TABLE PUBLIC.CUSTOMER(
ID BIGINT DEFAULT (NEXT VALUE FOR PUBLIC.SYSTEM_SEQUENCE_4588CEFE_3044_4D32_97C4_C1C11E955B18) NOT NULL NULL_TO_DEFAULT SEQUENCE PUBLIC.SYSTEM_SEQUENCE_4588CEFE_3044_4D32_97C4_C1C11E955B18,
FIRST_NAME VARCHAR(255),
LAST_NAME VARCHAR(255)
);
ALTER TABLE PUBLIC.CUSTOMER ADD CONSTRAINT PUBLIC.CONSTRAINT_5 PRIMARY KEY(ID);
-- 4 +/- SELECT COUNT(*) FROM PUBLIC.CUSTOMER;
INSERT INTO PUBLIC.CUSTOMER(ID, FIRST_NAME, LAST_NAME) VALUES
(1, 'Jack', 'Bauer'),
(2, 'Chloe', 'Bauer'),
(3, 'Kim', 'Palmer'),
(4, 'Michelle', 'Dessler');
CREATE MEMORY TABLE PUBLIC.CUSTOMER_ORDER(
ID BIGINT DEFAULT (NEXT VALUE FOR PUBLIC.SYSTEM_SEQUENCE_15FFA372_F73F_4953_BA6C_F2B82D5B0073) NOT NULL NULL_TO_DEFAULT SEQUENCE PUBLIC.SYSTEM_SEQUENCE_15FFA372_F73F_4953_BA6C_F2B82D5B0073,
CUSTOMER_ID BIGINT
);
ALTER TABLE PUBLIC.CUSTOMER_ORDER ADD CONSTRAINT PUBLIC.CONSTRAINT_3 PRIMARY KEY(ID);
-- 2 +/- SELECT COUNT(*) FROM PUBLIC.CUSTOMER_ORDER;
INSERT INTO PUBLIC.CUSTOMER_ORDER(ID, CUSTOMER_ID) VALUES
(1, 1),
(2, 2);
CREATE MEMORY TABLE PUBLIC.CUSTOMER_ORDER_PRODUCTS(
CUSTOMER_ORDER_ID BIGINT NOT NULL,
PRODUCT_ID BIGINT NOT NULL
);
-- 2 +/- SELECT COUNT(*) FROM PUBLIC.CUSTOMER_ORDER_PRODUCTS;
INSERT INTO PUBLIC.CUSTOMER_ORDER_PRODUCTS(CUSTOMER_ORDER_ID, PRODUCT_ID) VALUES
(1, 1),
(1, 2);
CREATE MEMORY TABLE PUBLIC.PRODUCT(
ID BIGINT DEFAULT (NEXT VALUE FOR PUBLIC.SYSTEM_SEQUENCE_8F149D1C_F851_4266_B1D7_FE96DB954A8D) NOT NULL NULL_TO_DEFAULT SEQUENCE PUBLIC.SYSTEM_SEQUENCE_8F149D1C_F851_4266_B1D7_FE96DB954A8D,
COST FLOAT NOT NULL,
DESCRIPTION VARCHAR(255),
NAME VARCHAR(255),
SALE_PRICE FLOAT NOT NULL
);
ALTER TABLE PUBLIC.PRODUCT ADD CONSTRAINT PUBLIC.CONSTRAINT_1 PRIMARY KEY(ID);
-- 2 +/- SELECT COUNT(*) FROM PUBLIC.PRODUCT;
INSERT INTO PUBLIC.PRODUCT(ID, COST, DESCRIPTION, NAME, SALE_PRICE) VALUES
(1, 19.989999771118164, '', 'TEST Product', 29.985000610351562),
(2, 19.989999771118164, '', 'Another Product', 29.985000610351562);
ALTER TABLE PUBLIC.CUSTOMER_ORDER_PRODUCTS ADD CONSTRAINT PUBLIC.FK9LPQ4QK4RVGP5VQC2LS0R0C7J FOREIGN KEY(PRODUCT_ID) REFERENCES PUBLIC.PRODUCT(ID) NOCHECK;
ALTER TABLE PUBLIC.CUSTOMER_ORDER ADD CONSTRAINT PUBLIC.FKF9ABD30BHIQVUGAYXLPQ8RYQ9 FOREIGN KEY(CUSTOMER_ID) REFERENCES PUBLIC.CUSTOMER(ID) NOCHECK;
ALTER TABLE PUBLIC.CUSTOMER_ORDER_PRODUCTS ADD CONSTRAINT PUBLIC.FK64QSEBVFLNGK3TFN5MQ94FR7L FOREIGN KEY(CUSTOMER_ORDER_ID) REFERENCES PUBLIC.CUSTOMER_ORDER(ID) NOCHECK;