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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!