Code Monkey home page Code Monkey logo

saadahmedwaqar / data-warehousing-redshift Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 421 KB

A Data Warehousing project for retail sales using dimension modelling best practices with SCD type 2 on AWS Redshift. Utilizing AWS Lambda, Glue Workflows and Python Shell jobs to create and automate an ELT pipeline where batch data coming into S3 is loaded onto Redshift and necessary transformations are performed to meet requirements.

Python 73.51% PLpgSQL 26.49%
aws-glue aws-redshift aws-s3 data-warehousing dimensional-modeling scd-type-2

data-warehousing-redshift's Introduction

Data-Warehousing-Redshift

Problem: S3(Relational Data) to Star Schema ETL

Part 1: Relational Schema Design:

  1. Customers (CustomerID, FirstName, LastName, Email, Address, City, State, ZipCode, LastModified)
  2. Products (ProductID, ProductName, Category, Description, Price, LastModified)
  3. Stores (StoreID, StoreName, Address, City, State, ZipCode, LastModified)
  4. Orders (OrderID, CustomerID, StoreID, OrderDate, TotalPrice, LastModified)
  5. OrderDetails (OrderID, ProductID, Quantity, Price, LastModified)

Part 2: Data Population

Use ChatGPT or any other data generation method to populate the CSV files with random data for each table. Ensure that the data is realistic and consistent with the schema.

Part 3: Data Import to S3 Bucket

• Create an S3 bucket in your AWS account. • Upload these CSV files to the S3 bucket.

Part 4: Data Copy to Redshift Cluster

• Create a Redshift cluster in your AWS account. • Configure the necessary security groups, network settings, and access permissions. • Use the Redshift COPY command to load the data from the S3 bucket into the Redshift tables. Ensure that the tables are created in Redshift with the same schema as in the csv file.

Part 5: Data Transformation to Star Schema (SCD Type 2) and Upserting using Staging Table

• Create a star schema for retail sales. • Write SQL queries to transform the data from the relational schema into a star schema using SCD Type 2. Perform the necessary data transformations to populate these tables with the appropriate historical changes using SCD Type 2. • Update and Insert (upsert) the updated data in the star schema using staging tables. • It is assumed that every table will have a directory in S3 and a new file will be uploaded each time there’s an update in the data. There will be a new file in S3 location.

Part 6: Insights Generation with SQL Queries

Write SQL queries to extract insights from the transformed star schema. Top Selling Products: Find the top 10 best-selling products based on the total quantity sold. Include the product name, category, and the total quantity sold.

Monthly Sales Trend:

Determine the monthly sales trend by calculating the total sales revenue for each month in a given year. Sales Performance Comparison: Compare the sales performance of different stores by calculating the total sales revenue for each store. Rank the stores based on their sales revenue.

Seasonal Sales Analysis:

Analyze the seasonal sales patterns by calculating the total sales revenue for each quarter of a given year. Identify the quarter with the highest sales revenue. Average Order Value: Calculate the average order value by dividing the total sales revenue by the total number of orders. Analyze the average order value trends over time and identify any significant changes.

Store Location Analysis:

Analyze the sales performance based on store location by calculating the total sales revenue for each city or state

Part 7 : Create a Data Pipeline to automate above tasks

Solution:

Dimesional Modelling Flow Diagram

Flow Diagram

data-warehousing-redshift's People

Contributors

saadahmedwaqar avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

gabrieljerdhy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.