MongoDB Database Assignment: Data Insertion, Queries, and Analysis

Verified

Added on  2024/05/15

|14
|1052
|365
Practical Assignment
AI Summary
This assignment details the creation of a MongoDB database and the execution of various queries on the created database. It includes the successful insertion of data into a collection named 'GameData' and demonstrates queries such as listing all games, retrieving specific fields like game titles, filtering games based on price and release date, and calculating average prices. The assignment also covers updating documents, adding new columns, and discusses the benefits and issues associated with using MongoDB, such as its schemaless nature and potential reliability concerns. Recommendations are provided to leverage MongoDB's strengths while mitigating its weaknesses. Desklib provides a platform to access this and other solved assignments.
tabler-icon-diamond-filled.svg

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Table of Contents
Introduction................................................................................................................................2
Part A.........................................................................................................................................3
Part B:.......................................................................................................................................11
References................................................................................................................................14
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
Introduction
In this assignment, we will create the database by inserting the given data in MongoDB. We
are also going to perform some queries on the database that we have created. The data is
described. The benefits and issues are also discussed.
2
Document Page
Part A
Data is successfully inserted in the collection name “GameData”. All the queries are
performed on this collection. The Queries are written and shown by the respective
screenshots:
1. List all the games in the collection (including all fields)
db.GameData.find( { mainGenre: "Games" })
Screenshot:
2. List only the game titles for all games.
db.GameData.find( { },{ title: 1} )
Screenshot:
3
Document Page
3. List only the game titles that are free.
db.GameData.find({ price: 0 },{ title: 1 })
Screenshot:
4. List only the game title and directors name for every game
db.GameData.find(
4
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
{ }, {title: 1, developerName: 1})
Screenshot:
5. List only the distinct names of every director.
db.GameData.distinct( "developerName")
Screenshot:
5
Document Page
6. Count the number of games in the collection.
db.GameData.aggregate( [
{ $count: "gameId" }])
Screenshot:
7. List only the game title and price for games that are less than $4.
db.GameData.find( { price: { $lt: 4 } },{title : 1 })
Screenshot:
6
Document Page
8. List only the game title, release date for the games that were released before 2016
db.getCollection("GameData3").find(
{
"releaseDate" : {
"$lt" : "1-1-2016"
}
}
);
Screenshot:
9. Return the average price each advisory rating (i.e. 4+ and 12+)
db.GameData.aggregate([{$group: {_id:null, pop: {$avg:"$price"} } }]);
Screenshot:
7
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
10. Return the game titles that do not support the Apple Watch device
db.GameData.find(
{
"supportedDevices" : {
"$not" : /^.*Watch.*$/i
}
});
Screenshot:
11. Return the game title and the file size in MB
db.GameData.stats(1024 * 1024)
{
fileSizeBytes : 682428,
avgObjSize : 0,
}
8
Document Page
12. Update
db.GameData.updateMany
(
{
title: "Word Warp - A Word Puzzle Game"
},
{
$set :
{
currentVersion : "3.3.5",
currentVersionNotes : "currentVersionNotes",
averageUserRatingForCurrentVersion : 4,
userRatingCountForCurrentVersion : 14
}
})
Screenshot:
9
Document Page
13. Add New Column:
db.GameData.update({},{$set : { developerCountry : "US"}} , true, true)
Screenshot:
10
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
Part B:
Columns Data type
developerID Integer
title String
description String
mainGenre String
genre2 String
Genre3 String
Genre4 String
releaseDate Date
supportedDevices String
contentAdvisoryRating String
language1 String
Language2 String
Language3 String
Language4 String
Language5 String
Language6 String
Language7 String
Language8 String
fileSizeBytes Integer
minOsVersion String
developerID Integer
developerName String
developerUrl String
price Double
currency String
averageUserRating decimal
userRatingCount Integer
currentVersion String
currentVersionReleaseDate Date
11
Document Page
currentVersionNotes String
Benefit of MongoDB
This does not create complexity in joining the tables.
This has a single structure object which is very clear.
This has the mapping/conversion of the objects application to have the database which
does not need the object.
Deep query ability which supports the MongoDB supports the queries which are dynamic
on the document using the various based query which have the powerful language of the
query as SQL.
MongoDB has an easy scale which means it has ease of sale out.
Uses of the memory for storing the working set which enables for the faster access of
data.
Schemaless there only one collection present which holds to have different documents
with the number of content, number of fields and size which have the different from the
other document.
Issue in MongoDB
There are a number of issues present in the MongoDB software that are required to be
sorted out. The present issues are referred to as:
Reliability is the first and most important issue that is mostly being encountered where
the writes of MongoDB are asynchronous.
The next important design to be considered is the issues related to the schema or the
structure of the design. But we all know that the design of MongoDB is not at all
normalized, therefore it does not adhere to the relational schema.
The next issue is that it is comparatively a bit complex that causes a lot of problems and
doesn’t provide easy implementation as well as extraction as compared to the other
databases.
12
Document Page
The next thing to be considered is the main conclusion part that belongs to the issues
being discussed above in the report. The presence of the 3rd part libraries is here for the
solution of the discussed issues.
Recommendation
Despite all the issues MongoDB is efficient to store the database or to create the database.
It provides concurrent access to the readers and the writers of the documents of
collection.
It also provides data consistency by facilitating the write-ahead logging.
It also provides a trusted networking environment so that can’t be lost.
13
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
References
Botoeva, E., Calvanese, D., Cogrel, B., & Xiao, G. (2018). Expressivity and complexity of
MongoDB queries. In 21st International Conference on Database Theory (ICDT 2018).
Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik.
James, R. (2015). U.S. Patent Application No. 13/948,610.
14
chevron_up_icon
1 out of 14
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]