-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_tables.sql
111 lines (103 loc) · 2.4 KB
/
create_tables.sql
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
# ---> Capstone data here
CREATE TABLE public.dimension_state (
state_key varchar(2) NOT NULL,
state_name varchar(256),
average_age numeric(3,2),
female_urban_population numeric(18,0),
male_urban_population numeric(18,0),
total_urban_population numeric(18,0),
CONSTRAINT state_key_pkey PRIMARY KEY(state_key)
);
CREATE TABLE public.fact_arrivals (
arrival_id integer,
state_key varchar(2) NOT NULL,
month integer,
average_age numeric(4,2),
F integer,
M integer,
U integer,
X integer,
business numeric(18,0),
pleasure numeric(18,0),
student numeric(18,0),
average_temperature numeric(4,2),
CONSTRAINT arrival_id_pkey PRIMARY KEY(arrival_id)
);
# ---> end of capstone
CREATE TABLE public.artists (
artistid varchar(256) NOT NULL,
name varchar(256),
location varchar(256),
lattitude numeric(18,0),
longitude numeric(18,0)
);
CREATE TABLE public.songplays (
playid varchar(32) NOT NULL,
start_time timestamp NOT NULL,
userid int4 NOT NULL,
"level" varchar(256),
songid varchar(256),
artistid varchar(256),
sessionid int4,
location varchar(256),
user_agent varchar(256),
CONSTRAINT songplays_pkey PRIMARY KEY (playid)
);
CREATE TABLE public.songs (
songid varchar(256) NOT NULL,
title varchar(256),
artistid varchar(256),
"year" int4,
duration numeric(18,0),
CONSTRAINT songs_pkey PRIMARY KEY (songid)
);
CREATE TABLE public.staging_events (
artist varchar(256),
auth varchar(256),
firstname varchar(256),
gender varchar(256),
iteminsession int4,
lastname varchar(256),
length numeric(18,0),
"level" varchar(256),
location varchar(256),
"method" varchar(256),
page varchar(256),
registration numeric(18,0),
sessionid int4,
song varchar(256),
status int4,
ts int8,
useragent varchar(256),
userid int4
);
CREATE TABLE public.staging_songs (
num_songs int4,
artist_id varchar(256),
artist_name varchar(256),
artist_latitude numeric(18,0),
artist_longitude numeric(18,0),
artist_location varchar(256),
song_id varchar(256),
title varchar(256),
duration numeric(18,0),
"year" int4
);
CREATE TABLE public."time" (
start_time timestamp NOT NULL,
"hour" int4,
"day" int4,
week int4,
"month" varchar(256),
"year" int4,
weekday varchar(256),
CONSTRAINT time_pkey PRIMARY KEY (start_time)
) ;
CREATE TABLE public.users (
userid int4 NOT NULL,
first_name varchar(256),
last_name varchar(256),
gender varchar(256),
"level" varchar(256),
CONSTRAINT users_pkey PRIMARY KEY (userid)
);