Write queries on data stored in a relational database

Assignment Help Python Programming
Reference no: EM132505936

Part 1 Overview
In this MP, we are going to explore AWS RDS, ElastiCache as well as S3, and how using ElastiCache can boost RDS performance. Specifically, you will build a storage service to support read and write queries on data stored in a relational database. The read and write APIs are built using Lambda functions. Your goal is to demonstrate the performance benefits of using caching to improve performance of database queries.You have also been provided an airlines dataset consisting of 5 CSV files and you need to analyze this data and obtain meaningful insights from it. In order to do so, you would first have to perform a simplified version of ETL (Extract, Transform, Load) on these CSV files using AWS Glue. You will then select a subset of this data based on some constraints through AWS Athena using a SQL query. This filtered dataset will then be used inside Tableau for visualization and gaining further insight into it.

Requirements
You need a valid AWS account and will be working on AWS Athena, Glue, Lambda, API Gateway, RDS, ElastiCache and S3. Also, you need to be familiar with one of the following programming languages for implementing lambda: Python / Javascript / Java / Go. While we will make every attempt to help out irrespective of your chosen language, we can best assist with python 3. AWS Athena and Glue are available on educate accountsand install Tableau software on your local machine. You will need to learn SQL to perform filtering on top of Athena and get familiar with Tableau. Please use region -> us-east-1 for your deployment.

Part 3 Populate database and set up Redis cluster
3.1 Amazon S3 setup
First, we setup S3 bucket and load the content for populating the database.
Step 1: Set up an Amazon S3 bucket and upload mp11input.csv into the bucket, reference the tutorial:
3.2 Setup and populate Amazon Aurora
Step 2: Create an IAM policy and IAM role for Amazon Aurora to access Amazon S3
Next, create an IAM policy and IAM role for Amazon Aurora database, use the following tutorials for reference.

Step 3: Setup Amazon Aurora database
Create an Amazon Aurora database. Reference the 2 tutorials listed below, and use the following settings: Make sure publicly accessible is selected. For the DB cluster parameter group and DB parameter group, choose the ones created in step 1 and step 2. Attach the IAM role created in step 2 to the database just
Step 4: Populate database using data in Amazon S3
Next, load data from mp11input.csv which is stored in S3 bucket created in step 1 into database. Reference the tutorial:

3.3 Create a Redis Cluster
For creating a redis cluster, you can refer to the following tutorial:

Part 4 Create Lambda function
4.1 Setting up Lambda function
Unlike some of the previous MPs, third party libraries can be imported in this MP. If you choose to use Python for this MP, you will need to refer to the following tutorial for importing two modules pymysql and redis:

4.2 Read/Write API
There are different strategies of using cache. You can refer to this document for more
Specifically, the autograder will send read requests with the following format:
{
"USE_CACHE": "True",
"REQUEST": "read",
"SQLS": [
"25"
]
}
We would like you to return the corresponding rows with the ids that's in SQLS list (you need to create a list and append the corresponding rows to the list, which you need to return at the end of the api call). If USE_CACHE is true, check if Redis contains the id. If not, store the row returned by RDS in Redis, and then return the result. Note that choice of key and value in Redis is totally up to you. The autograder will only ask you for the corresponding rows of the ids.
Our lazy loading test will check if your implementation takes advantage of Redis and boosts the perfomance of querying data. You can test that on your own before submitting.
The write requests examples are as follows,
{
"USE_CACHE": "True",
"REQUEST": "write",
"SQLS": [
{
"hero": "yes",
"name": "fireman",
"power": "fire",
"color": "red",
"xp": "10"
},
{
"hero": "no",
"name": "dogman",
"power": "bark",
"color": "brown",
"xp": "50"
}
]
}
For write request, you will have to insert the new characters in Aurora. If USE_CACHE is true, we would like you to use write-through strategy. Our autograder will check whether your write-through implementation improves the read performance.

Return a JSON message to the API call as follows:
{
"statusCode": 200,
"body": result
}
where the result should be rows of data if responding to a read API call, and "write success" when responding to a write API call.
5 API setup
Set up an API endpoint for your Lambda function.

Part 7 Virtualization Procedure

7.1 AWS Glue Setup
You can download the dataset (flights-dataset.zip) ~ 50MB from below. Once you download this dataset, you will have to upload the csv files to your AWS account S3 storage in order for Glue to access it.
In order to run your ETL job on this S3 dataset, you need to first configure AWS Glue so that it has the metadata required to read from S3 and create/monitor your jobs. You will then use a crawler to populate the Glue Data catalog with the metadata for the datastore (S3 Bucket where the flights csv files are stored). Create a Database within the data catalog and run the crawler. It will create a table under that database. You should manually verify the relevant properties and the schema in order to ensure that the correct ones have been extracted by the crawler. The database and the table that you created through AWS Glue are also going to reflect in Athena.

7.2 Query and Filtering through AWS Athena

You should be able to view the table created through the Glue inside AWS Athena reflecting the total entries of 479230 (with header trimmed). You need to now come up with a SQL query for the following:
• Select all possible trips from SFO to JFK with 1 stop-over airport in between such that:
1. 60 minutes <= stop-over time <= 180 minutes. Here, the stop-over time is the difference between the arrival time of the first flight and departure time of the second flight. Note that we are using arrival time and departure time (not scheduled arrival time or scheduled departure time). Also, note that the format of timings in the dataset is in integer format as HHMM (i.e., 1730 means 5.30 PM). It is not necessary to covert the times to DateTime format, rather you can apply some simple calculations over the integer format.
2. The first flight leaving from SFO as well as the second flight leaving from the stop-over airport should have the same DAY column value.
3. Both the flights on a given trip should belong to the same airline.
You need to output the following columns for each trip: Day, Airline, Origin Airport, Stop-over Airport, Destination Airport, Origin Departure Delay, Stop-over Arrival Delay, Stop-over Departure Delay, Destination Arrival Delay. Note that there should be one row for each trip in the output. Please save the count of entries you obtain from your query as you would need to submit this parameter to the autograder.
Save the output results from this query in a CSV file that will be used by Tableau for the tasks below.

7.3 Tableau Setup
As a student, you're eligible for a free Tableau Desktop license through Tableau for Students. In order to download and install Tableau, you need to first fill out this form, providing your .illinois.edu email address.
Next, you will receive an email on your email account with download links along with the product key. You will be using the product key during installation.
Note that Tableau Desktop can only be installed on MacOS (version >=10.13) or Windows. You may have to use virtual machines if you are using other OSes.
If you would like more info on how to use Tableau, please check out the Tableau Tutorial.You can also refer to the first 30 minutes of this video.

7.4 Tableau Visualization
Using the output CSV from 3.2, you need to create two visualizations.
In the Tableau window, click on File menu and then New. Next, you need to connect to the CSV file. Once connected, you create two worksheets one for each of the tasks below, and save the results as mentioned.

1. Create a bar chart to show the count of flights between SFO and different stop-over airports. Now you need to save the data corresponding this visualization as follows: Right-click on the visualization, then click "View Data", ensure that "Summary Data" is selected at the bottom, and finally click on "Export All" to save the data into a file named "mp9-viz1.tsv" or "mp9-viz1.csv" depending on whether your file is tab or comma separated.

2. Create a scatter plot with Stop-over Departure Delay at the intermediate airport as x-axis and Destination Arrival Delay at JFK as Y-axis. Now create two filters: one for Stop-over Departure Delay, and another for Destination Arrival Delay. Set the range of Departure Delay filter from 200 to 260 and Arrival Delay filter from 110 to 220. Similar to the above task, you can now save the data corresponding to this visualization as follows: Right-click on the visualization, then click "View Data", ensure that "Summary Data" is selected at the bottom, and finally click on "Export All" to save the data into a file named "mp9-viz2.tsv" or "mp9-viz2.csv" depending on whether your file is tab or comma separated.

Attachment:- AWS Project.rar

Reference no: EM132505936

Questions Cloud

What the cost is a for lhk company : If the LHK Company had a per unit cost that was $5 when 400 units were produced and a per unit cost of $4 when 500 units were produced, the cost is a
Calculate the no-arbitrage price : Calculate the no-arbitrage price at which the U.S. Company could enter into a forward contract that expires in three months.
AC04-1 Introduction to Accounting Information Systems : AC04-1 Introduction to Accounting Information Systems Assignment Help and Solution - University of Bedfordshire - Majan University College, Oman
Show the before-and-after effects of the dividend : Show the before-and-after effects of the dividend on the The components of stockholders' equity, Shares outstanding, Par value per share.
Write queries on data stored in a relational database : Build a storage service to support read and write queries on data stored in a relational database. The read and write APIs are built using Lambda functions
Does financial services face a cyberwar in future : What is Critical Infrastructure mean and why financial services is a critical infrastrucre? Does financial services face a cyberwar in future?
Which alternative would logical and sensible investor choose : Which alternatives would a logical and sensible investor choose? Borrow money with an interest rate of 7% with monthly compounding
How has the term hacking changed meaning over the years : With all the stories about millions and millions of bytes of personal data having been exposed, why is their still any faith at all in the Internet?
Calculate using the investment appraisal techniques : Calculate using the following investment appraisal techniques, and provide brief recommendations as to the economic feasibility of acquiring the machine:

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd