Skip to content

parthsrudakia/Data_Warehousing-using-AWS-Redshift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

A music streaming startup, Sparkify, has grown their user base and song database and want to move their processes and data onto the cloud. Their data resides in S3, in a directory of JSON logs on user activity on the app, as well as a directory with JSON metadata on the songs in their app.

As their data engineer, we are tasked with building an ETL pipeline that extracts their data from S3, stages them in Redshift, and transforms data into a set of dimensional tables for their analytics team to continue finding insights into what songs their users are listening to. You'll be able to test your database and ETL pipeline by running queries given to you by the analytics team from Sparkify and compare your results with their expected results.

How to Run

--> First, we'll need an AWS Redshift Cluster up and running.

--> Now, fill up the params of Redshift Cluster in the dwh.cfg file.

  1. Run create_tables.py file.

  2. Run etl.py file.

--> Now the analytics tables are ready on the Redshift Cluster for our business user to query our data get useful insights.

Raw Data Info

Song Dataset

The first dataset is a subset of real data from the Million Song Dataset. Each file is in JSON format and contains metadata about a song and the artist of that song. The files are partitioned by the first three letters of each song's track ID. For example, here are file paths to two files in this dataset.

song_data/A/B/C/TRABCEI128F424C983.json
song_data/A/A/B/TRAABJL12903CDCF1A.json

And below is an example of what a single song file, TRAABJL12903CDCF1A.json, looks like.

{"num_songs": 1, "artist_id": "ARJIE2Y1187B994AB7", "artist_latitude": null, "artist_longitude": null, "artist_location": "", "artist_name": "Line Renaud", "song_id": "SOUPIRU12A6D4FA1E1", "title": "Der Kleine Dompfaff", "duration": 152.92036, "year": 0}

Log Dataset

The second dataset consists of log files in JSON format generated by this event simulator based on the songs in the dataset above. These simulate app activity logs from an imaginary music streaming app based on configuration settings.

The log files in the dataset you'll be working with are partitioned by year and month. For example, here are file paths to two files in this dataset.

log_data/2018/11/2018-11-12-events.json
log_data/2018/11/2018-11-13-events.json

Analytical Tables

Here we have chosen Star schema for our analytical tables. The reason to choose Star Schema is that a star schema can be more efficient to query than a snowflake schema, because there are fewer JOINs between tables.

Fact Table: songplays Dimension Tables: users, songs, artists, time_of_use

Here we have chosen song_id and artist_id as distkey for our Redshift cluser since we are our main focus is on the query that which songs users are listening to most.

Files

  1. create_tables.py: It creates a connection to the Redshift database using params from dwh.cfg and drops any existing tables with the same name and creates our staging tables and analytical tables.

  2. etl.py: First it creates a connection to the Redshift database. Then copies all log and song JSON files into staging tables then inserts the data into analytical tables in our Redshift database.

  3. sql_quueries.py: It has all the drop, create and insert into table queries for both of our staging tables and analytical tables.

  4. dwh.cfg: It has all the params we need to establish the connection to our Redshift Database. Make sure to fill this up before running any files.

  5. dashboard: I have made a tableau dashboard using some sample queries.

dwh.cfg:

[CLUSTER]
HOST=
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_PORT=

[IAM_ROLE]
ARN=''

[S3]
LOG_DATA='s3://udacity-dend/log_data'
LOG_JSONPATH='s3://udacity-dend/log_json_path.json'
SONG_DATA='s3://udacity-dend/song_data'


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages