MongoDB Database Assignment: Data Insertion, Queries, and Analysis
VerifiedAdded 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.

Table of Contents
Introduction................................................................................................................................2
Part A.........................................................................................................................................3
Part B:.......................................................................................................................................11
References................................................................................................................................14
Introduction................................................................................................................................2
Part A.........................................................................................................................................3
Part B:.......................................................................................................................................11
References................................................................................................................................14
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

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
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

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
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
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

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
db.GameData.find({ price: 0 },{ title: 1 })
Screenshot:
4. List only the game title and directors name for every game
db.GameData.find(
4
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

{ }, {title: 1, developerName: 1})
Screenshot:
5. List only the distinct names of every director.
db.GameData.distinct( "developerName")
Screenshot:
5
Screenshot:
5. List only the distinct names of every director.
db.GameData.distinct( "developerName")
Screenshot:
5

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
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
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

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
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
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

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
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

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
db.GameData.updateMany
(
{
title: "Word Warp - A Word Puzzle Game"
},
{
$set :
{
currentVersion : "3.3.5",
currentVersionNotes : "currentVersionNotes",
averageUserRatingForCurrentVersion : 4,
userRatingCountForCurrentVersion : 14
}
})
Screenshot:
9
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

13. Add New Column:
db.GameData.update({},{$set : { developerCountry : "US"}} , true, true)
Screenshot:
10
db.GameData.update({},{$set : { developerCountry : "US"}} , true, true)
Screenshot:
10
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

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
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

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
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
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 14
Related Documents

Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.