Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

COMPSCI 123: Introduction to NoSQL Injection Introduction to NoSQL | 2026 Update

Rating
-
Sold
-
Pages
46
Grade
A+
Uploaded on
12-05-2026
Written in
2025/2026

COMPSCI 123: Introduction to NoSQL Injection Introduction to NoSQL | 2026 Update

Institution
Course

Content preview

2. Introduction to NoSQL Injection
Introduction to NoSQL


Background
Many applications rely on databases to store data, such as passwords, email addresses, or
comments. The most popular database engines are relational (e.g. Oracle and MySQL).
However, over the past decade, non-relational databases, also known as NoSQL
databases, have become increasingly more common, with MongoDB now being the 5th most
used database engine (as of November 2022).

There are four main types of NoSQL databases, and unlike relational databases, which
all store data similarly in tables , rows , and columns , the way NoSQL databases store
data varies significantly across the different categories and implementations.
r
.i

Type Description Top 3 Engines (as of
01


November 2022)
Document- Stores data in documents which contain MongoDB, Amazon
de




Oriented pairs of fields and values . These DynamoDB, Google
Database documents are typically encoded in formats Firebase - Cloud
hi




such as JSON or XML . Firestore
Key-Value A data structure that stores data in Redis, Amazon
Database key:value pairs, also known as a DynamoDB, Azure
dictionary . Cosmos DB
Wide-Column Used for storing enormous amounts of data Apache Cassandra,
Store in tables , rows , and columns like a Apache HBase, Azure
relational database, but with the ability to Cosmos DB
handle more ambiguous data types.
Graph Stores data in nodes and uses edges to Neo4j, Azure Cosmos
Database define relationships. DB, Virtuoso


In this module, we will focus solely on MongoDB , as it is the most popular NoSQL database.




Introduction to MongoDB


https://t.me/CyberFreeCourses

,MongoDB is a document-oriented database, which means data is stored in collections
of documents composed of fields and values . In MongoDB , these documents are
encoded in BSON (Binary JSON). An example of a document that may be stored in a
MongoDB database is:


{
_id: ObjectId("63651456d18bf6c01b8eeae9"),
type: 'Granny Smith',
price: 0.65
}




Here we can see the document's fields (type, price) and their respective values ('Granny
Smith', '0.65'). The field _id is reserved by MongoDB to act as a document's primary key ,
and it must be unique throughout the entire collection .

Connecting to MongoDB
We can use mongosh to interact with a MongoDB database from the command line by
passing the connection string. Note that 27017/tcp is the default port for MongoDB.
r
.i

mongosh mongodb://127.0.0.1:27017
01


Current Mongosh Log ID: 636510136bfa115e590dae03
de




Connecting to: mongodb://127.0.0.1:27017/?
directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.0
hi




Using MongoDB: 6.0.2
Using Mongosh: 1.6.0


For mongosh info see: https://docs.mongodb.com/mongodb-shell/


test>




We can check which databases exist like this:


test> show databases
admin 72.00 KiB
config 108.00 KiB
local 40.00 KiB




Creating a Database

MongoDB does not create a database until you first store data in that database . We can
"switch" to a new database called academy by using the use command:
https://t.me/CyberFreeCourses

, test> use academy
switched to db academy
academy>




We can list all collections in a database with show collections .

Inserting Data
Similarly to creating a database, MongoDB only creates a collection when you first insert
a document into that collection . We can insert data into a collection in several ways.

We can insert a single document into the apples collection like this:


academy> db.apples.insertOne({type: "Granny Smith", price: 0.65})
{
acknowledged: true,
insertedId: ObjectId("63651456d18bf6c01b8eeae9")
}
r
.i

And we can insert multiple documents into the apples collection like this:
01


academy> db.apples.insertMany([{type: "Golden Delicious", price: 0.79},
de




{type: "Pink Lady", price: 0.90}])
{
hi




acknowledged: true,
insertedIds: {
'0': ObjectId("6365147cd18bf6c01b8eeaea"),
'1': ObjectId("6365147cd18bf6c01b8eeaeb")
}
}




Selecting Data

Let's say we wanted to check the price of Granny Smith apples. One way to do this is by
specifying a document with fields and values we want to match:


academy> db.apples.find({type: "Granny Smith"})
{
_id: ObjectId("63651456d18bf6c01b8eeae9"),
type: 'Granny Smith',
price: 0.65
}



https://t.me/CyberFreeCourses

, Or perhaps we wanted to list all documents in the collection. We can do this by passing an
empty document (since it is a subset of all documents):


academy> db.apples.find({})
[
{
_id: ObjectId("63651456d18bf6c01b8eeae9"),
type: 'Granny Smith',
price: 0.65
},
{
_id: ObjectId("6365147cd18bf6c01b8eeaea"),
type: 'Golden Delicious',
price: 0.79
},
{
_id: ObjectId("6365147cd18bf6c01b8eeaeb"),
type: 'Pink Lady',
price: 0.90
}
]
r
.i
01


If we wanted to do more advanced queries, such as finding all apples whose type
starts with a 'G' and whose price is less than 0.70 , we would have to use a
de




combination of query operators. There are many query operators in MongoDB, but some
of the most common are:
hi




Type Operator Description Example
Comparison $eq Matches values which are type: {$eq: "Pink Lady"}
equal to a specified value

Comparison $gt Matches values which are price: {$gt: 0.30}
greater than a specified
value
Comparison $gte Matches values which are price: {$gte: 0.50}
greater than or equal to
a specified value
Comparison $in Matches values which exist type: {$in: ["Granny
in the specified array Smith", "Pink Lady"]}

Comparison $lt Matches values which are price: {$lt: 0.60}
less than a specified value

Comparison $lte Matches values which are price: {$lte: 0.75}
less than or equal to a
specified value


https://t.me/CyberFreeCourses

Written for

Institution
Course

Document information

Uploaded on
May 12, 2026
Number of pages
46
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$18.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
PassPointExams Brown University
Follow You need to be logged in order to follow users or courses
Sold
181
Member since
3 year
Number of followers
170
Documents
2715
Last sold
2 weeks ago
Where preparation meets precision

A results-driven exam shop delivering exam-ready questions, rationales, and pass-focused study guides. Designed to help students hit the exact point where passing happensno fluff, no overload.

4.1

49 reviews

5
31
4
5
3
5
2
2
1
6

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions