Professional Documents
Culture Documents
FA20-BCS-053, Lab Assignment-4, DB
FA20-BCS-053, Lab Assignment-4, DB
FA20-BCS-053, Lab Assignment-4, DB
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
[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
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]
"following":800,
"followers":7000,
"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",
],
"Messages_recieved":[{
"sender_username":"_haseeb7",
"reciever_username":"_ali99",
"Date":"7-June-2020",
},
"sender_username":"_haseeb7",
"reciever_username":"_ali99",
"Date":"7-June-2020",
}
],
"Spaces":[{
"participants":"2000",
"category":"Educational",
"date":"20-June-2020",
},
"participants":"20000",
"category":"Entertainment",
"date":"24-June-2020",
}],
"tweets":[{
"Date":"7-June-2020",
"likes":"2001",
"link":"https://twitter.com/tweet1?q=%23login",
"commentOnTweet":[{
"comment_text":"Finally!!",
"Date":"7-June-2020"
},
"Date":"8-June-2020"
}]
},
"Date":"9-June-2020",
"likes":"201",
"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,
"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",
],
"Messages_recieved":[{
"sender_username":"_haseeb7",
"reciever_username":"_hassan99",
"Date":"7-June-2020",
},
{
"sender_username":"_haseeb7",
"reciever_username":"_hassan99",
"Date":"7-June-2020",
],
"Spaces":[{
"participants":"2000",
"category":"Educational",
"date":"20-June-2020",
},
"participants":"20000",
"category":"Entertainment",
"date":"24-June-2020",
}],
"tweets":[{
"Date":"7-June-2020",
"likes":"2001",
"link":"https://twitter.com/tweet1?q=%23login",
"commentOnTweet":[{
"comment_text":"Finally!!",
"Date":"7-June-2020"
},
"Date":"8-June-2020"
}]
},
"Date":"9-June-2020",
"likes":"201",
"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.