-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql_template.txt
61 lines (50 loc) · 1.53 KB
/
mysql_template.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
CREATE DATABASE store_database;
USE store_database;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
is_admin BOOLEAN NOT NULL
);
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
product_name VARCHAR(255) NOT NULL,
product_price INT NULL,
custom_price BOOLEAN NULL
);
CREATE TABLE transactions (
id INT AUTO_INCREMENT PRIMARY KEY,
transaction_total INT NOT NULL,
product_type_total INT NOT NULL,
transaction_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE product_transactions (
id INT AUTO_INCREMENT PRIMARY KEY,
product_id INT,
transaction_id INT,
product_custom_price_id INT,
FOREIGN KEY (product_id) REFERENCES products(id),
FOREIGN KEY (transaction_id) REFERENCES transactions(id),
FOREIGN KEY (product_custom_price_id) REFERENCES custom_product_price(id),
product_quantity INT NOT NULL,
product_bill INT NOT NULL
);
CREATE TABLE custom_product_price (
id INT AUTO_INCREMENT PRIMARY KEY,
product_id INT,
price INT,
price_information VARCHAR(255) NOT NULL,
FOREIGN KEY (product_id) REFERENCES products(id)
);
INSERT INTO users (username, password, is_admin) VALUES
('admin', 'admin', true),
('user','user',false);
INSERT INTO products (product_name,product_price) VALUES
('Aqua Mini', 2000),
('Aqua Tanggung',3000),
('Aqua Besar', 5000),
('Aqua Gelas', 1000),
('In Mild', 22000),
('Mie Sedap Goreng', 4000),
('Indomie Goreng', 4000),
('Coca-cola', 5000);