Skip to content

sudip-padhye/Data-Modeling-of-Music-Streaming-App-with-Postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Modeling & ETL Pipeline for Sparkify using Postgres


Introduction

Sparkify is a music streaming app. The analytics team is particularly interested in understanding what songs users are listening to. Currently, their data resides 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. However, this cannot provid an easy way to query the data.

The log files in the dataset are partitioned by year and month.

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.

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 activity logs from a music streaming app based on specified configurations.

The goal


The purpose of this project is to create a Postgres database and ETL pipeline to optimize queries to help Sparkify's analytics team.

Database & ETL pipeline


Using the song and log datasets, I created a star schema as shown below, which includes

  • 1 fact table: songplays, and
  • 4 dimension tables: users, songs, artists and time.

drawing

Steps to execute code

  1. Unzip data.7z folder.
  2. Run create_tables.py to create your database and tables.

python create_tables.py

  1. Open and execute test.ipynb to confirm the creation of your tables with the correct columns. Make sure to click "Restart kernel" to close the connection to the database after running this notebook.
  2. Run etl.py to execute ETL process which loads entire data from json files into corresponding tables.

python etl.py

  1. Run test.ipynb to confirm that records were successfully inserted into each table.