/AWS_DWH_p3

Primary LanguagePython

Data Warehouse with Amazon Web Service (AWS)

  • This is one of the projects of my Udacity Data Engineer NanoDegree Program

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 in what songs their users are listening to. We'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.

Project Description

In this project, we'll make use AWS to build an ETL pipeline for a database hosted on Redshift. We will load data from S3 to staging tables on Redshift and execute SQL statements that create the analytics tables from these staging tables.

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 filepaths to two files in this dataset.

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

The second dataset consists of log files in JSON format generated by event simulator based on the songs in the dataset above. These simulate activity logs from a music streaming app based on specified configurations.

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

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

Schema for Song Play Analysis

Using the song and event datasets, you'll need to create a star schema optimized for queries on song play analysis. This includes the following tables.
p2

Package required

import os
import glob
import psycopg2
import pandas as pd
import boto3
import json

Implementation steps

  1. Use AWS to build the RedShift Cluster
    p1

  2. Edit the dwh.cfg to complete the HOST, ROLE, DB_NAME....etc to connect the RedShift cluster

  3. Define all the SQL in sql_queries.py

  4. run the create_tables.py to creat fact and dimension tables in Star Schema in RedShift

  5. run the etl.py to load the data from S3 into staging tables on Redshift to perform ETL process, then move to analytics tables on Redshift

  6. We can perform any OLAP on AWS


More about me

[:pencil:My Medium]
[:house_with_garden:My Website]
[:space_invader: My Github]