FA20-BCS-053, Lab Assignment-4, DB

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Database Systems

LAB Assignment 4

Submitted By:
Name: Muhammad Haseeb
Reg No: FA20-BCS-053
Course: Database Systems
Date of Submission: 26th June 2022

Submitted To:
Sir Qasim Malik
COMSATS UNIVERSITY, ISLAMABAD
Department of Computer Science
Lab Assignment-4, Spring-2022
Using Non-Relational DBMS, MongoDB, for Data Storage and Retrieval

Course: Database Systems - I (CSC371) Class: BCS IV


Instructor: Qasim Malik Total Marks:
10

[CLO-C2, CLO-C3]

Part-I [CLO-C3]: For the problem you solved in your lab midterm, now let’s assume we want to reverse
engineer the data oriented non-relational database design for the following three social media platforms:

 Facebook
 Youtube  Twitter

Each of you will work on one of the above platforms. In order to determine the platform on which you will be
working, use the following formula:

Last_three_digits_of_your_registration_no modulus 3

where 0 refers to the Facebook, 1 to the Youtube, and 2 to the Twitter.

For the same set of requirements, you modeled in your Entity Relationship Diagram in lab midterm, now
transform it into MongoDB collection(s) and provide a sample document(s) of it in JSON format. [4]

Part-II [CLO-C2]: Insert a few meaningful documents in the collection. [2]

Answer Part-I + Part-ll:

"following":800,

"followers":7000,

"Bio": "Hello people!!",

"username":"_ali99",

"location":"Islamabad, Pakistan",

"DOB": "9-May-2000",

"Credentials":{

"phone": "+92231213321",

"email":"ali@gmail.com",
"name":"Muhammad Haseeb"

},

"Messages_sent":[{

"sender_username":"_ali99",

"reciever_username":"_haseeb7",

"Date":"7-June-2020",

"Message":"Hello"

},

"sender_username":"_ali99",

"reciever_username":"_haseeb7",

"Date":"7-June-2020",

"Message":"How are you?"

],

"Messages_recieved":[{

"sender_username":"_haseeb7",

"reciever_username":"_ali99",

"Date":"7-June-2020",

"Message":"How are you?"

},

"sender_username":"_haseeb7",

"reciever_username":"_ali99",

"Date":"7-June-2020",

"Message":"Where are you now a day's?"

}
],

"Spaces":[{

"participants":"2000",

"category":"Educational",

"date":"20-June-2020",

"Title":"Adaptive physical education"

},

"participants":"20000",

"category":"Entertainment",

"date":"24-June-2020",

"Title":"Q/A sessions and Podcast"

}],

"tweets":[{

"Date":"7-June-2020",

"likes":"2001",

"tweet_text":"Which #altcoin are you buying this dip?",

"link":"https://twitter.com/tweet1?q=%23login",

"commentOnTweet":[{

"comment_text":"Finally!!",

"Date":"7-June-2020"

},

"comment_text":"Waiting for this!!",

"Date":"8-June-2020"

}]
},

"Date":"9-June-2020",

"likes":"201",

"tweet_text":"Anyone experiencing this? #instagramdown #login #issues",

"link":"https://twitter.com/tweet2?q=%23login",

"commentOnTweet":[{

"comment_text":"Yes!!",

"Date":"10-June-2020"

},

"comment_text":"It's a bug!!",

"Date":"10-June-2020"

}]

}],

"quote_tweets":[{

"qt_Date":"7-June-2020",

"qt_likes":"20",

"qt_tweet_text":"SOLE",

"qt_link":"https://twitter.com/qttweet1?q=%23login",

"link":"https://twitter.com/tweet1?q=%23login",

"commentOnTweet":[{

"comment_text":"Good!!",

"Date":"8-June-2020"

},

"comment_text":"Interested!!",
"Date":"8-June-2020"

}]

}],

"trend":[{

"ranking":1,

"tweets": "44K",

"hashtag":"#Crypto"

},

"ranking":2,

"tweets": "30K",

"hashtag":"#Cricket"

},

"ranking":3,

"tweets": "70K",

"hashtag":"#Pakistan_Zindabad"

}]

"following":80,

"followers":70,

"Bio": "Hello people!!",

"username":"_hassan9",

"location":"Lahore, Pakistan",
"DOB": "19-May-2000",

"Credentials":{

"phone": "+92231213321",

"email":"hassan@gmail.com",

"name":"Muhammad Hassan"

},

"Messages_sent":[{

"sender_username":"_hassan99",

"reciever_username":"_haseeb7",

"Date":"7-June-2020",

"Message":"Hello"

},

"sender_username":"_hassan99",

"reciever_username":"_haseeb7",

"Date":"7-June-2020",

"Message":"How are you?"

],

"Messages_recieved":[{

"sender_username":"_haseeb7",

"reciever_username":"_hassan99",

"Date":"7-June-2020",

"Message":"How are you?"

},

{
"sender_username":"_haseeb7",

"reciever_username":"_hassan99",

"Date":"7-June-2020",

"Message":"Where are you now a day's?"

],

"Spaces":[{

"participants":"2000",

"category":"Educational",

"date":"20-June-2020",

"Title":"Adaptive physical education"

},

"participants":"20000",

"category":"Entertainment",

"date":"24-June-2020",

"Title":"Q/A sessions and Podcast"

}],

"tweets":[{

"Date":"7-June-2020",

"likes":"2001",

"tweet_text":"Which #altcoin are you buying this dip?",

"link":"https://twitter.com/tweet1?q=%23login",

"commentOnTweet":[{

"comment_text":"Finally!!",

"Date":"7-June-2020"
},

"comment_text":"Waiting for this!!",

"Date":"8-June-2020"

}]

},

"Date":"9-June-2020",

"likes":"201",

"tweet_text":"Anyone experiencing this? #instagramdown #login #issues",

"link":"https://twitter.com/tweet2?q=%23login",

"commentOnTweet":[{

"comment_text":"Yes!!",

"Date":"10-June-2020"

},

"comment_text":"It's a bug!!",

"Date":"10-June-2020"

}]

}],

"quote_tweets":[{

"qt_Date":"7-June-2020",

"qt_likes":"20",

"qt_tweet_text":"SOLE",

"qt_link":"https://twitter.com/qttweet1?q=%23login",

"link":"https://twitter.com/tweet1?q=%23login",

"commentOnTweet":[{
"comment_text":"Good!!",

"Date":"8-June-2020"

},

"comment_text":"Interested!!",

"Date":"8-June-2020"

}]

}],

"trend":[{

"ranking":1,

"tweets": "44K",

"hashtag":"#Crypto"

},

"ranking":2,

"tweets": "30K",

"hashtag":"#Cricket"

},

"ranking":3,

"tweets": "70K",

"hashtag":"#Pakistan_Zindabad"

}]

}
Part-III [CLO-C2]: Now in this part, you are going to first create a meaningful query in English and then
provide the corresponding MongoDB API call for each of the following situations:

 Think of a need that requires issuing find API call involving the use of logical and comparison
operators. [2]
Query: Show user profile with followers greater than 500 and who lives in Islamabad, Pakistan.

 Think of a need that require issuing aggregate API call with at least five stages including the group
stage and the use of any aggregation operation. [2]

Query: Show a user profile with username _ali99 and his sum of tweets using aggregation.

You might also like