Movie Maniacs Site: MongoDB Database Queries Assignment for ICT704

Verified

Added on  2023/06/04

|8
|1695
|481
Homework Assignment
AI Summary
This assignment solution demonstrates the application of MongoDB database concepts, focusing on a movie database scenario. It includes the creation of indexes to optimize query performance, followed by a series of queries designed to retrieve specific data. The queries cover various operations, including finding documents based on different criteria (e.g., MovieID, country, director), distinct value retrieval, counting documents, and updating documents. Aggregation queries are also implemented to perform more complex data analysis, such as joining data from multiple collections (Movie and Rating) and calculating average ratings. Finally, the assignment concludes with a comprehensive bibliography of relevant resources used in the assignment.
Document Page
Running head: MONGODB DATABASE
MongoDB Database
Name of the Student
Name of the University
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
1MONGODB DATABASE
Table of Contents
Part A: Query.............................................................................................................................2
Index 1:...................................................................................................................................2
Index 2:...................................................................................................................................2
Index 3:...................................................................................................................................2
Query 1:..................................................................................................................................2
Query 2:..................................................................................................................................2
Query 3:..................................................................................................................................2
Query 4:..................................................................................................................................2
Query 5:..................................................................................................................................2
Query 6:..................................................................................................................................2
Query 7:..................................................................................................................................3
Query 8:..................................................................................................................................3
Query 9:..................................................................................................................................3
Query 10:................................................................................................................................3
Query 11:................................................................................................................................3
Bibliography:..............................................................................................................................5
Document Page
2MONGODB DATABASE
Part A: Query
Index 1:
db.getCollection('Movie').createIndex( { MovieID: 1 } );
Index 2:
db.getCollection('Movie').createIndex( { MovieID: 1 }, { collation: { Country: "Japan" } } );
Index 3:
db.getCollection('Movie').createIndex( { MovieName: 1 }, { collation: { Country:
"Japan" } } );
Query 1:
db.getCollection('Movie').find({}, {MovieID: '1', '_id':0})
Query 2:
db.getCollection('Movie').find({Country: 'Japan'})
Query 3:
db.getCollection('Movie').find({}, {MovieName: 1, Director: 1, '_id':0})
Query 4:
db.getCollection('Movie').find({}, {MovieName: '2001', Director: 'Japan', '_id':0})
Query 5:
db.getCollection('Movie').distinct("Director")
Query 6:
db.getCollection('Movie').count({}, {MovieID: 1, '_id':0})
Document Page
3MONGODB DATABASE
Query 7:
db.Movie.find({OscarsWon: { $exists: false }})
Query 8:
db.getCollection('Movie').find({ReleaseDate: {$lte: '1968'}})
Query 9:
db.Movie.aggregate([{$lookup:{from:"Movie", localField: "MovieID",
foreignField: "MovieID", as: "MovieRating"}}, {$replaceRoot: { newRoot:
{ $mergeObjects: [ { $arrayElemAt: [ "$MovieRating", 0 ] }, "$$ROOT" ] } } }, {$group:
{_id: {Movie: "$MovieID", MovieName: "$MovieName"}, averageRating: {$avg:
"$Rating"}}}]);
Query 10:
db.Movie.aggregate([{ $lookup:{from:"Rating", localField: "MovieID", foreignField:
"MovieID", as: "MovieRating"}}, {$replaceRoot: { newRoot: { $mergeObjects:
[ { $arrayElemAt: [ "$MovieRating ", 0 ] }, "$$ROOT" ] } } }, {$project : {"MovieName":
1, MovieRating: {"Rating": 1, "Comments": 1}}}]);
Query 11:
db.Movie.update(
{ MovieName: "ET" },
{
MovieID: "6",
MovieName: "E.T.",
Director: "Steven Spielberg",
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
4MONGODB DATABASE
ReleaseDate: "1982",
OscarsWon: "4",
Country: "USA"
},
{ upsert: true }
)
Query 12: db.getCollection
('Movie').update
({MovieID: "12"},
{$set:{ notes: "Terminator and Terminator 2 are rated together"}})
db.getCollection
('Movie').update
({MovieID: "18"},
{$set:{ notes: "The trilogy consists of the three movies "}})
Document Page
5MONGODB DATABASE
Bibliography:
Abbes, H. and Gargouri, F., 2016, December. M2Onto: an approach and a tool to learn OWL
ontology from MongoDB database. In International Conference on Intelligent Systems
Design and Applications (pp. 612-621). Springer, Cham.
Abbes, H. and Gargouri, F., 2016. Big data integration: A MongoDB database and modular
ontologies based approach. Procedia Computer Science, 96, pp.446-455.
Abbes, H., Boukettaya, S. and Gargouri, F., 2015, November. Learning ontology from big
data through MongoDB database. In Computer Systems and Applications (AICCSA), 2015
IEEE/ACS 12th International Conference of (pp. 1-7). IEEE.
Aboutorabi, S.H., Rezapour, M., Moradi, M. and Ghadiri, N., 2015, August. Performance
evaluation of SQL and MongoDB databases for big e-commerce data. In Computer Science
and Software Engineering (CSSE), 2015 International Symposium on (pp. 1-7). IEEE.
Chauhan, D. and Bansal, K.L., 2017. Using the Advantages of NoSQL: A case study on
MongoDB. International Journal on Recent and Innovation Trends in Computing and
Communication, 5(2), pp.90-93.
Dupont, C., Wussah, A., Malo, S., Thiare, O., Niass, F., Pham, C., Dupont, S., Le Gall, F. and
Cousin, P., 2018, May. Low-Cost IoT Solutions for Fish Farmers in Africa. In 2018 IST-
Africa Week Conference (IST-Africa) (pp. Page-1). IEEE.
Ferney, M.M.J., Estefan, L.B.N. and Alexander, V.V.J., 2017, October. Assessing data
quality in open data: A case study. In de Innovacion y Tendencias en Ingenieria (CONIITI),
2017 Congreso Internacional (pp. 1-5). IEEE.
Document Page
6MONGODB DATABASE
Gousios, G., Vasilescu, B., Serebrenik, A. and Zaidman, A., 2014, May. Lean GHTorrent:
GitHub data on demand. In Proceedings of the 11th working conference on mining software
repositories (pp. 384-387). ACM.
Guimaraes, V., Hondo, F., Almeida, R., Vera, H., Holanda, M., Araujo, A., Walter, M.E. and
Lifschitz, S., 2015, November. A study of genomic data provenance in NoSQL document-
oriented database systems. In Bioinformatics and Biomedicine (BIBM), 2015 IEEE
International Conference on (pp. 1525-1531). IEEE.
Gyorodi, C., Gyorodi, R., Pecherle, G. and Olah, A., 2015, June. A comparative study:
MongoDB vs. MySQL. In Engineering of Modern Electric Systems (EMES), 2015 13th
International Conference on (pp. 1-6). IEEE.
Inel, O., Khamkham, K., Cristea, T., Dumitrache, A., Rutjes, A., van der Ploeg, J.,
Romaszko, L., Aroyo, L. and Sips, R.J., 2014, October. Crowdtruth: Machine-human
computation framework for harnessing disagreement in gathering annotated data. In
International Semantic Web Conference (pp. 486-504). Springer, Cham.
Kanoje, S., Powar, V. and Mukhopadhyay, D., 2015, March. Using MongoDB for social
networking website deciphering the pros and cons. In Innovations in Information, Embedded
and Communication Systems (ICIIECS), 2015 International Conference on (pp. 1-3). IEEE.
Kumar, L., Rajawat, S. and Joshi, K., 2015. Comparative analysis of nosql (mongodb) with
mysql database. International Journal of Modern Trends in Engineering and Research, 2(5),
pp.120-127.
Le, M.K., Chang, H.T., Chang, Y.M., Hu, Y.H. and Chen, H.T., 2016, December. An
efficient multilevel healthy cloud system using Spark for smart clothes. In Computer
Symposium (ICS), 2016 International (pp. 182-186). IEEE.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7MONGODB DATABASE
Michel, F., Faron-Zucker, C. and Montagnat, J., 2016, September. A mapping-based method
to query MongoDB documents with SPARQL. In International Conference on Database and
Expert Systems Applications (pp. 52-67). Springer, Cham.
Michel, F., Zucker, C.F. and Montagnat, J., 2016. Mapping-based SPARQL access to a
MongoDB database (Doctoral dissertation, CNRS).
Mohamed, H.H.H., 2015. A new auditing mechanism for open source NoSQL database a
case study on open source MongoDB database (Doctoral dissertation, Universiti Utara
Malaysia).
Shukla, K. and Khare, P., 2018. A SIMPLIFIED WAY OF DATABASE MIGRATION
FROM RELATIONAL DATABASE MYSQL TO NOSQL DATABASE MONGODB.
Simanjuntak, H.T., Simanjuntak, L., Situmorang, G. and Saragih, A., 2015. Query Response
Time Comparison NOSQLDB MONGODB with SQLDB Oracle. JUTI: Jurnal Ilmiah
Teknologi Informasi, 13(1), pp.95-105.
Stanescu, L., Brezovan, M. and Burdescu, D.D., 2016, September. Automatic mapping of
MySQL databases to NoSQL MongoDB. In Computer Science and Information Systems
(FedCSIS), 2016 Federated Conference on (pp. 837-840). IEEE.
Wu, C.M., Huang, Y.F. and Lee, J., 2015. Comparisons between mongodb and ms-sql
databases on the twc website. American Journal of Software Engineering and Applications,
4(2), pp.35-41.
chevron_up_icon
1 out of 8
circle_padding
hide_on_mobile
zoom_out_icon
logo.png

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]