Question
HAVING A PROBLEM WITH PROBLEM E but does the other answers look good? We will use a full day worth of tweets as an input
HAVING A PROBLEM WITH PROBLEM E but does the other answers look good?
We will use a full day worth of tweets as an input (there are total of 4.4M tweets in this file, but you only need to read 1M): http://rasinsrv07.cstcis.cti.depaul.edu/CSC455/OneDayOfTweets.txt
Write and execute SQL queries to do the following. Dont forget to report the running times in each part and the code you used.
# Create Table Tweets
c.execute('''CREATE TABLE tweet
(
created_at DATETIME,
user_id INT,
id_str TEXT,
text TEXT,
source TEXT,
in_reply_to_user_id INT,
in_reply_to_screen_name TEXT,
in_reply_to_status_id INT,
retweet_count INT,
contributors TEXT
CONSTRAINT tweet_FK
FOREIGN KEY (user_id) REFERENCES user(id),
)''')
# Create Table User
c.execute('''CREATE TABLE user
(
id INT,
screen_name TEXT,
description TEXT,
friends_count INT,
contributors TEXT
CONSTRAINT USER_PK
PRIMARY KEY(ID)
)''')
# Create Table User
c.execute('''CREATE TABLE Geo
(
user_id INT,
type TEXT,
longitude INT,
latitude INT,
CONSTRAINT tweet_FK_2
FOREIGN KEY (user_id) REFERENCES tweet(user_id)
)''')
a)Find tweets where tweet id_str contains 44 or 77 anywhere in the column
Select id_str from tweet
Where id_str = %44% or id_str = %77%
b)Find how many unique values are there in the in_reply_to_user_id column
Select count(distinct in_reply_to_user_id) as reply_count
FROM tweet
c)Find the tweet(s) with the shortest, longest and average length text message.
Select MIN(LEN(Text)) AVG(LEN(text)) MAX((LEN(text)) from tweet
d)Find the average longitude and latitude value for each user name.
Select screen_name longitude latitude from user inner join Geo inner join
user where user_id= id
Order by text
E)Re-execute the query in part iv) 10 times and 100 times and measure the total runtime (just re-run the same exact query multiple times using a for-loop). Does the runtime scale linearly? (i.e., does it take 10X and 100X as much time?)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started