-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
167 lines (138 loc) · 4.31 KB
/
database.sql
File metadata and controls
167 lines (138 loc) · 4.31 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
create table customers(
id varchar(255) not null primary key,
name varchar(255) not null
) engine InnoDB;
alter table customers
add column primary_email varchar(150);
create table categories(
id int not null auto_increment primary key,
name varchar(100) not null,
description varchar(500)
)engine InnoDB;
alter table customers
add column age tinyint;
alter table customers
add column married boolean;
alter table customers
add column type varchar(50);
alter table categories
add column created_at timestamp;
alter table categories
add column updated_at timestamp;
create table images(
id int not null auto_increment primary key,
name varchar(100) not null,
description text,
image blob
)engine InnoDB;
create table members(
id int not null auto_increment primary key,
email varchar(150) not null,
title varchar(100),
first_name varchar(100)not null,
middle_name varchar(100),
last_name varchar(100)
)engine InnoDB;
create table departments(
company_id varchar(100) not null,
department_id varchar(100) not null,
name varchar(150) not null,
primary key (company_id, department_id)
)engine InnoDB;
create table hobbies(
id int not null auto_increment primary key,
member_id int not null,
name varchar(150) not null,
foreign key fk_members_hobbies (member_id)
references members (id)
)engine InnoDB;
create table skills(
id int not null auto_increment primary key,
member_id int not null,
name varchar(100) not null,
value int not null,
foreign key fk_members_skills (member_id)
references members (id),
constraint skills_unique unique (member_id, name)
)engine InnoDB;
create table credentials(
id varchar(100) not null primary key,
email varchar(150) not null,
password varchar(150) not null
)engine InnoDB;
create table users(
id varchar(100) not null primary key,
name varchar(150) not null
)engine InnoDB;
create table wallet(
id int not null auto_increment primary key,
user_id varchar(100) not null,
balance bigint not null,
foreign key fk_users_wallet (user_id) references users(id)
)engine InnoDB;
create table brands(
id varchar(100) not null primary key,
name varchar(150) not null,
description varchar(500)
)engine InnoDB;
create table products(
id varchar(100) not null primary key,
brand_id varchar(100) not null,
name varchar(100) not null,
price bigint not null,
description varchar(500),
foreign key fk_brands_products (brand_id) references brands(id)
)engine InnoDB;
create table users_like_products(
user_id varchar(100) not null,
product_id varchar(100) not null,
foreign key fk_users_to_users_like_products (user_id) references users(id),
foreign key fk_products_to_users_like_products (product_id) references products(id),
primary key (user_id, product_id)
)engine InnoDB;
create table employees(
id varchar(100) not null primary key,
type varchar(50) not null,
name varchar(100) not null,
total_manager int,
total_employee int
)engine InnoDB;
create table payments(
id varchar(100) not null primary key,
amount bigint not null
)engine InnoDB;
create table payments_gopay(
id varchar(100) not null primary key,
gopay_id varchar(100) not null,
foreign key fk_payments_gopay (id) references payments(id)
)engine InnoDB;
create table payments_credit_card(
id varchar(100) not null primary key,
masked_card varchar(100) not null,
bank varchar(100) not null,
foreign key fk_payments_credit_card (id) references payments(id)
)engine InnoDB;
create table transactions(
id varchar(100) not null primary key,
balance bigint not null,
created_at timestamp not null
)engine InnoDB;
create table transactions_credit(
id varchar(100) not null primary key,
balance bigint not null,
created_at timestamp not null,
credit_amount bigint not null
)engine InnoDB;
create table transactions_debit(
id varchar(100) not null primary key,
balance bigint not null,
created_at timestamp not null,
debit_amount bigint not null
)engine InnoDB;
alter table brands
add column created_at timestamp;
alter table brands
add column updated_at timestamp;
alter table brands
add column version bigint;
create database belajar_java_persistence_api_test;