krisnadwipaj commited on
Commit
eb36fa6
·
1 Parent(s): 8aac2a0

this file is to create diagram relation in dbdiagram.io

Browse files
Files changed (1) hide show
  1. retail_banking.sql +161 -0
retail_banking.sql ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ create database retail_banking;
2
+ use retail_banking;
3
+ create table dim_completeddistrict(
4
+ district_id int primary key,
5
+ city text,
6
+ state_name text,
7
+ state_abbrev text,
8
+ region text,
9
+ division text
10
+ );
11
+ create table dim_completedacct(
12
+ account_id text primary key,
13
+ district_id int,
14
+ frequency text,
15
+ parseddate date,
16
+ foreign key(district_id) references dim_completeddistrict(district_id)
17
+ );
18
+ create table fact_crm_call_center_logs(
19
+ date_received date,
20
+ complaint_id text,
21
+ rand_client text,
22
+ phonefinal text,
23
+ vru_line text,
24
+ call_id int,
25
+ priority int,
26
+ type text,
27
+ outcome text,
28
+ server text,
29
+ ser_start time,
30
+ ser_exit time,
31
+ ser_time time,
32
+ foreign key(rand_client) references dim_completedclient(client_id)
33
+ );
34
+ create table dim_completedclient(
35
+ client_id text primary key,
36
+ sex text,
37
+ date_of_birth date,
38
+ age int,
39
+ social text,
40
+ fullname text,
41
+ phone text,
42
+ email text,
43
+ address_1 text,
44
+ addres_2 text,
45
+ city text,
46
+ state text,
47
+ zipcode text,
48
+ district_id int,
49
+ foreign key(district_id) references dim_completeddistrict(district_id)
50
+ );
51
+ create table dim_completeddisposition(
52
+ disp_id text primary key,
53
+ client_id text,
54
+ account_id text,
55
+ type text,
56
+ foreign key(client_id) references dim_completedclient(client_id),
57
+ foreign key(account_id) references dim_completedacct(account_id)
58
+ );
59
+ create table dim_completedcard(
60
+ card_id text primary key,
61
+ disp_id text,
62
+ type text,
63
+ fulldate date,
64
+ foreign key(disp_id) references dim_completeddisposition(disp_id)
65
+ );
66
+ create table fact_completedloan(
67
+ loan_id text primary key,
68
+ account_id text,
69
+ amount double,
70
+ duration int,
71
+ payments double,
72
+ `status` text,
73
+ fulldate date,
74
+ location text,
75
+ purpose text,
76
+ foreign key(account_id) references dim_completedacct(account_id)
77
+ );
78
+ create table fact_completedtrans(
79
+ trans_id text primary key,
80
+ account_id text,
81
+ type text,
82
+ operation text,
83
+ amount double,
84
+ balance double,
85
+ k_symbol text,
86
+ bank text,
87
+ account text,
88
+ fulldatewithtime timestamp,
89
+ foreign key(account_id) references dim_completedacct(account_id),
90
+ constraint FK_order foreign key(account) references fact_completedorder(account_to)
91
+ );
92
+ create table fact_completedorder(
93
+ order_id int primary key,
94
+ account_id text,
95
+ bank_to text,
96
+ account_to text,
97
+ amount double,
98
+ k_symbol text,
99
+ foreign key(account_id) references dim_completedacct(account_id)
100
+ );
101
+ create table fact_crm_events(
102
+ date_received date,
103
+ product text,
104
+ sub_product text,
105
+ issue text,
106
+ sub_issue text,
107
+ consumer_complaint_narrative text,
108
+ tags text,
109
+ is_consumer_consent_provided text,
110
+ submitted_via text,
111
+ date_sent_to_company text,
112
+ company_response_to_consumer text,
113
+ is_timely_response text,
114
+ is_consumer_disputed text,
115
+ complaint_id text,
116
+ client_id text,
117
+ constraint FK_crm_call foreign key(complaint_id) references fact_crm_call_center_logs(complaint_id),
118
+ foreign key(client_id) references dim_completedclient(client_id)
119
+ );
120
+ create table dim_crm_reviews(
121
+ date date,
122
+ `stars` int,
123
+ reviews text,
124
+ product text,
125
+ district_id int,
126
+ foreign key(district_id) references dim_completeddistrict(district_id)
127
+ );
128
+ create table dim_luxury_loan_portfolio(
129
+ loan_id text primary key,
130
+ funded_amount double,
131
+ funded_date text,
132
+ duration_years int,
133
+ duration_months int,
134
+ ten_yr_treasury_index_date_funded double,
135
+ interest_rate_percent double,
136
+ interest_rate double,
137
+ payments double,
138
+ total_past_payments int,
139
+ loan_balance double,
140
+ property_value double,
141
+ purpose text,
142
+ firstname text,
143
+ middlename text,
144
+ lastname text,
145
+ social text,
146
+ phone text,
147
+ title text,
148
+ employment_length int,
149
+ building_class_category text,
150
+ present_tax_class text,
151
+ present_building_class text,
152
+ address_1 text,
153
+ addres_2 text,
154
+ zip_code int,
155
+ city text,
156
+ state text,
157
+ total_units int,
158
+ land_square_feet text,
159
+ gross_square_feet text,
160
+ tax_class_at_time_of_sale int
161
+ );