-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_database.sql
More file actions
209 lines (191 loc) · 4.58 KB
/
create_database.sql
File metadata and controls
209 lines (191 loc) · 4.58 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
CREATE DATABASE auditors;
\connect auditors
CREATE TABLE actions(
date DATE,
action VARCHAR,
ticker VARCHAR,
name VARCHAR,
value DECIMAL,
contraticker VARCHAR,
contraname VARCHAR
);
COPY actions(date, action, ticker, name, value, contraticker, contraname)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/actions.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE daily(
ticker VARCHAR,
date DATE,
lastupdated DATE,
ev DECIMAL,
evebit DECIMAL,
evebitda DECIMAL,
marketcap DECIMAL,
pb DECIMAL,
pe DECIMAL,
ps DECIMAL
);
COPY daily(ticker, date, lastupdated, ev, evebit, evebitda, marketcap, pb, pe, ps)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/daily.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE events(
ticker VARCHAR,
date DATE,
eventcodes VARCHAR
);
COPY events(ticker, date, eventcodes)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/events.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE indicators(
_table VARCHAR,
indicator VARCHAR,
isfilter VARCHAR,
isprimarykey VARCHAR,
title VARCHAR,
description VARCHAR,
unittype VARCHAR
);
COPY indicators(_table, indicator, isfilter, isprimarykey, title, description, unittype)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/indicators.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE sf1(
ticker VARCHAR,
dimension VARCHAR,
calendardate DATE,
reportperiod DATE,
lastupdated DATE,
assets NUMERIC,
capex NUMERIC,
ncfbus NUMERIC,
ncfinv NUMERIC,
ncff NUMERIC,
ncfdebt NUMERIC,
ncfcommon NUMERIC,
ncfdiv NUMERIC,
ncfi NUMERIC,
ncfo NUMERIC,
liabilities NUMERIC,
debtusd NUMERIC,
ebitdausd NUMERIC,
netinccmnusd NUMERIC,
equityusd NUMERIC,
revenueusd NUMERIC,
cashnequsd NUMERIC,
marketcap NUMERIC,
ev NUMERIC
);
COPY sf1(ticker, dimension, calendardate, reportperiod, lastupdated,
assets, capex, cashnequsd, debtusd, ebitdausd, equityusd,
ev, liabilities, marketcap, ncfbus, ncfcommon, ncfdebt,
ncfdiv, ncff, ncfi, ncfinv, ncfo, netinccmnusd,
revenueusd
)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/sf1_columns.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE sp500(
date DATE,
action VARCHAR,
ticker VARCHAR,
name VARCHAR,
contraticker VARCHAR,
contraname VARCHAR,
note VARCHAR
);
COPY sp500(date, action, ticker, name, contraticker, contraname, note)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/sp500.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE tickers(
_table VARCHAR,
permaticker VARCHAR,
ticker VARCHAR,
name VARCHAR,
exchange VARCHAR,
isdelisted VARCHAR,
category VARCHAR,
cusips VARCHAR,
siccode VARCHAR,
sicsector VARCHAR,
sicindustry VARCHAR,
famasector VARCHAR,
famaindustry VARCHAR,
sector VARCHAR,
industry VARCHAR,
scalemarketcap VARCHAR,
scalerevenue VARCHAR,
relatedtickers VARCHAR,
currency VARCHAR,
location VARCHAR,
lastupdated DATE,
firstadded DATE,
firstpricedate DATE,
lastpricedate DATE,
firstquarter DATE,
lastquarter DATE,
secfilings VARCHAR,
companysite VARCHAR
);
COPY tickers(_table,
permaticker,
ticker,
name,
exchange,
isdelisted,
category,
cusips,
siccode,
sicsector,
sicindustry,
famasector,
famaindustry,
sector,
industry,
scalemarketcap,
scalerevenue,
relatedtickers,
currency,
location,
lastupdated,
firstadded,
firstpricedate,
lastpricedate,
firstquarter,
lastquarter,
secfilings,
companysite)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/tickers.csv'
DELIMITER ','
CSV HEADER;
CREATE TABLE firm_filings(
firm_name VARCHAR,
firm_country VARCHAR,
audit_report_type VARCHAR,
issuer_id DECIMAL,
issuer_name VARCHAR,
issuer_ticker VARCHAR,
firm_issuing_country VARCHAR,
firm_issuing_city VARCHAR,
firm_issuing_state VARCHAR,
is_multiple_audit_period BOOLEAN,
signed_date DATE,
filing_date DATE
);
COPY firm_filings(firm_name,
firm_country,
audit_report_type,
issuer_id,
issuer_name,
issuer_ticker,
firm_issuing_country,
firm_issuing_city,
firm_issuing_state,
is_multiple_audit_period,
signed_date,
filing_date)
FROM '/Users/dunleavyjason/Documents/Metis/auditors/auditor_database_files/firm_filings_columns.csv'
DELIMITER ','
CSV HEADER;