-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathregopz.sql
More file actions
390 lines (323 loc) · 11.7 KB
/
regopz.sql
File metadata and controls
390 lines (323 loc) · 11.7 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
rename table business_rules to business_rules_0526;
create table business_rules (
id bigint not null primary key auto_increment,
rule_execution_order VARCHAR(15) NOT NULL,
business_rule varchar(15) NOT NULL,
source_id SMALLINT NOT NULL,
rule_description VARCHAR(300),
logical_condition VARCHAR(300),
data_fields_list VARCHAR(600),
python_implementation VARCHAR(2000),
business_or_validation VARCHAR(10),
rule_type VARCHAR(15),
valid_from datetime,
valid_to datetime,
last_updated_by VARCHAR(20),
country VARCHAR(2)
);
insert into business_rules select id,rule_execution_order,business_rule,source_id, rule_description,logical_condition, data_fields_list, python_implementation,business_or_validation, rule_type, null, null, null,'SG' from business_rules_0526; id bigint not null primary key auto_increment
rename table report_def to report_def_0526;
create table report_def (
id bigint not null primary key auto_increment
report_id VARCHAR(32) NOT NULL,
sheet_id VARCHAR(32) NOT NULL,
cell_id VARCHAR(10) NOT NULL,
cell_render_def VARCHAR(32) NOT NULL,
cell_calc_ref VARCHAR(1000) NOT NULL,
valid_from datetime,
valid_to datetime,
last_updated_by VARCHAR(100),
country VARCHAR(2),
);
insert into report_def select report_id,sheet_id,cell_id,cell_render_def,cell_calc_ref,null,null,null,'SG' from report_def_0526;
rename table report_calc_def to report_calc_def_0526;
create table report_calc_def (
source_id SMALLINT NOT NULL,
report_id VARCHAR(32) NOT NULL,
sheet_id VARCHAR(32) NOT NULL,
cell_id VARCHAR(10) NOT NULL,
cell_calc_ref VARCHAR(30) NOT NULL,
cell_business_rules VARCHAR(2000) NOT NULL,
aggregation_ref VARCHAR(1000) NOT NULL,
aggregation_func VARCHAR(1000) NOT NULL,
valid_from datetime,
valid_to datetime,
last_updated_by VARCHAR(100),
country VARCHAR(2),
id bigint not null primary key auto_increment
);
insert into report_calc_def select source_id,report_id,sheet_id,cell_id,cell_calc_ref,cell_business_rules,aggregation_ref,
aggregation_func,null,null,null,'SG'
from report_calc_def_0526;
rename table report_comp_agg_def to report_comp_agg_def_0526;
create table report_comp_agg_def(
report_id VARCHAR(32) NOT NULL,
sheet_id VARCHAR(32) NOT NULL,
cell_id VARCHAR(10) NOT NULL,
comp_agg_ref VARCHAR(2000) NOT NULL,
reporting_scale FLOAT NOT NULL,
rounding_option VARCHAR(50),
valid_from datetime,
valid_to datetime,
last_updated_by VARCHAR(100),
country VARCHAR(2),
id bigint not null primary key auto_increment
);
insert into report_comp_agg_def select report_id,sheet_id,cell_id,comp_agg_ref,reporting_scale,rounding_option,
null,null,null,'SG'
from report_comp_agg_def_0526;
rename table calendar to calendar_0526;
CREATE TABLE calendar (
business_date VARCHAR(8) NOT NULL,
holiday_working VARCHAR(2) NOT NULL,
country VARCHAR(2) NOT NULL,
last_updated_by VARCHAR(100),
id DECIMAL(8) not null primary key
);
insert into calendar
select business_date, holiday_working,country,null,business_date
from calendar_0526;
rename table exchange_rate to exchange_rate_0526;
CREATE TABLE exchange_rate (
from_currency VARCHAR(3) NOT NULL,
to_currency VARCHAR(3) NOT NULL,
rate FLOAT NOT NULL,
business_date DECIMAL(8) NOT NULL,
rate_type VARCHAR(20) NOT NULL,
country VARCHAR(2) NOT NULL,
last_updated_by VARCHAR(100),
id bigint not null primary key auto_increment
);
insert into exchange_rate
select from_currency, to_currency,rate,business_date,rate_type,'SG',null,null
from exchange_rate_0526 where length(from_currency)=3;
rename table manual_adjustment to manual_adjustment_0526;
CREATE TABLE manual_adjustment (
report_id VARCHAR(32) NOT NULL,
sheet_id VARCHAR(32) NOT NULL,
cell_id VARCHAR(10) NOT NULL,
adjustment_value VARCHAR(1000),
currency VARCHAR(3),
comment VARCHAR(1000),
business_date DECIMAL(8) NOT NULL,
id bigint not null primary key auto_increment
);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
create table data_source_col_name(
id bigint not null primary key auto_increment,
source_id SMALLINT NOT NULL,
business_date int(8),
source_table_name VARCHAR(32) NOT NULL,
column_name varchar(100),
column_datatype varchar(100),
column_default_value varchar(100),
column_is_nullable varchar(100),
column_max_length int(11),
column_key varchar(255),
column_display_name varchar(255),
column_comment varchar(1000)
);
create table data_source_information (
id bigint not null primary key auto_increment,
source_id SMALLINT NOT NULL,
source_table_name VARCHAR(32) NOT NULL,
source_description VARCHAR(1000),
source_file_name VARCHAR(200) NOT NULL,
source_file_delimiter VARCHAR(1) NOT NULL,
last_updated_by VARCHAR(255),
country VARCHAR(2)
);
rename table qualified_data to qualified_data_20170619;
CREATE TABLE qualified_data (
source_id SMALLINT NOT NULL,
qualifying_key BIGINT NOT NULL,
business_rules varchar(3000) NOT NULL,
buy_currency VARCHAR(3),
sell_currency VARCHAR(3),
mtm_currency VARCHAR(3),
business_date int(8)
);
CREATE TABLE qualified_data (
//id bigint not null primary key auto_increment,
source_id SMALLINT NOT NULL,
qualifying_key BIGINT NOT NULL,
business_rules varchar(3000) NOT NULL,
buy_currency VARCHAR(3),
sell_currency VARCHAR(3),
mtm_currency VARCHAR(3),
business_date int(8),
data_ver VARCHAR(200),
data_ver_timestamp DATETIME
);
rename table invalid_data to invalid_data_20170619;
create table invalid_data (
source_id SMALLINT NOT NULL,
qualifying_key BIGINT NOT NULL,
business_rules varchar(3000) NOT NULL,
business_date int(8)
);
create table invalid_data (
source_id SMALLINT NOT NULL,
qualifying_key BIGINT NOT NULL,
business_rules varchar(3000) NOT NULL,
business_date int(8),
data_ver TEXT,
data_ver_timestamp DATETIME
);
rename table report_qualified_data_link to report_qualified_data_link_20170619;
CREATE TABLE report_qualified_data_link (
source_id SMALLINT NOT NULL,
report_id VARCHAR(32) NOT NULL,
sheet_id VARCHAR(32) NOT NULL,
cell_id VARCHAR(10) NOT NULL,
cell_calc_ref VARCHAR(100) NOT NULL,
buy_currency VARCHAR(3),
sell_currency VARCHAR(3),
mtm_currency VARCHAR(3),
qualifying_key BIGINT NOT NULL,
business_date int(8) NOT NULL,
reporting_date BIGINT NOT NULL,
buy_reporting_rate float,
sell_reporting_rate float,
mtm_reporting_rate float,
buy_usd_rate float,
sell_usd_rate float,
mtm_usd_rate float
);
CREATE TABLE report_qualified_data_link (
//id bigint not null primary key auto_increment
source_id SMALLINT NOT NULL,
report_id VARCHAR(32) NOT NULL,
sheet_id VARCHAR(32) NOT NULL,
cell_id VARCHAR(10) NOT NULL,
cell_calc_ref VARCHAR(100) NOT NULL,
buy_currency VARCHAR(3),
sell_currency VARCHAR(3),
mtm_currency VARCHAR(3),
qualifying_key BIGINT NOT NULL,
business_date int(8) NOT NULL,
reporting_date BIGINT NOT NULL,
buy_reporting_rate float,
sell_reporting_rate float,
mtm_reporting_rate float,
buy_usd_rate float,
sell_usd_rate float,
mtm_usd_rate float,
data_ver int(8),
data_ver_timestamp DATETIME
);
rename table report_summary_by_source to report_summary_by_source_20170619;
CREATE TABLE report_summary_by_source (
source_id SMALLINT NOT NULL,
report_id VARCHAR (32) NOT NULL,
sheet_id VARCHAR (32) NOT NULL,
cell_id VARCHAR (10) NOT NULL,
cell_calc_ref VARCHAR(100) NOT NULL,
cell_summary float,
reporting_date BIGINT NOT NULL
);
CREATE TABLE report_summary_by_source (
source_id SMALLINT NOT NULL,
report_id VARCHAR (32) NOT NULL,
sheet_id VARCHAR (32) NOT NULL,
cell_id VARCHAR (10) NOT NULL,
cell_calc_ref VARCHAR(100) NOT NULL,
cell_summary float,
reporting_date BIGINT NOT NULL
);
rename table report_summary to report_summary_20170619;
CREATE TABLE report_summary (
report_id VARCHAR (32) NOT NULL,
sheet_id VARCHAR (32) NOT NULL,
cell_id VARCHAR (10) NOT NULL,
cell_summary float,
reporting_date BIGINT NOT NULL
);
CREATE TABLE report_summary (
report_id VARCHAR (32) NOT NULL,
sheet_id VARCHAR (32) NOT NULL,
cell_id VARCHAR (10) NOT NULL,
cell_summary float,
reporting_date BIGINT NOT NULL
);
create table report_catalog(
id
report_id bigint,
reporting_date int(8),
as_of_reporting_date int(16),
report_create_date int(8),
report_create_timestamp int(25),
report_parameters text,
report_create_status varchar(255),
//report_version TEXT,
//report_version_timestamp DATETIME,
);
create table data_loading_catalog(
id BIGINT
source_id SMALLINT NOT NULL
business_date text,
data_file_name text,
number_of_rows text,
file_load_status text,
header_row text,
);
********************************************
LOG TABLE
********************************************
Here list partioning can be done over 'change_category_id' and 'operation_category_id' column if the int value is stored.
Categories for data change are : business_rule_change, report_calc_def_change, etc.
Categories for operation change are : data_loading, business_rules_apply, report_calc_def_apply, running_report_aggregation
create table data_change_log (
id BIGINT,
source_id SMALLINT NOT NULL
business_date int(8),
change_category_id int(25),
field_name varchar(255),
old_val varchar(1000),
new_val varchar(1000),
change_type varchar(255),
date_of_change int(8),
maker varchar(255), // user_id
checker varchar(255), // user_id
checker_status varchar(20),
date_of_checking int(8)
);
create table operational_log (
id BIGINT,
source_id SMALLINT NOT NULL,
business_date int(8),
operation_category_id int(25),
operation_type varchar(255),
date_of_operation int(8),
operation_status varchar(25),
operation_naration varchar(2000)
maker varchar(255), // user_id foreign_Key
checker varchar(255), // user_id foreign_key
checker_status varchar(20),
date_of_checking int(8)
);
***********LOG TABLE END****************
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
USER ACCESS CONTROL TABLES
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
create table users(
uid BIGINT NOT NULL
name text
);
create table roles(
id bigint,
role_name text,
);
create table role_permission(
id bigint,
role_id bigint,
permission text,
);
create table users_roles(
uid BIGINT NOT NULL,
rid bigint,
);
9674759106 tk basu
ttirthabasu@gmail.com