0% found this document useful (0 votes)
6 views9 pages

Unit 2 (Chapter 5) - Big Data Technologies

This document provides an overview of MongoDB, a NoSQL database known for its flexibility, scalability, and high performance. It covers key features, advantages, data types, and the MongoDB Query Language (MQL) used for database interactions. Additionally, it highlights the applications of MongoDB in various domains such as real-time analytics and content management.

Uploaded by

Prasad Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Unit 2 (Chapter 5) - Big Data Technologies

This document provides an overview of MongoDB, a NoSQL database known for its flexibility, scalability, and high performance. It covers key features, advantages, data types, and the MongoDB Query Language (MQL) used for database interactions. Additionally, it highlights the applications of MongoDB in various domains such as real-time analytics and content management.

Uploaded by

Prasad Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 1

Big Data Analytics


Unit-2 (Chapter - 5: Big Data Technologies)
• MongoDB - What is MongoDB?
• Why MongoDB?
• Terms Used in RDBMS and MongoDB,
• Data Types in MongoDB,
• MongoDB Query Language.

MongoDB - What is MongoDB?


MongoDB is a NoSQL, open-source, cross-platform database developed by MongoDB Inc., and it's
part of the MEAN (MongoDB, Express, Angular, Node.js) and MERN (MongoDB, Express, React,
Node.js) stacks, which are popular for full-stack development.
MongoDB is a NoSQL database that stores data in a flexible, JSON-like format called BSON (Binary
JSON). Unlike traditional relational databases (like MySQL or PostgreSQL), which store data in tables
with rows and columns, MongoDB stores data in collections made up of documents.

Why Use MongoDB?


❖ Perfect for big data, real-time analytics, content management, IoT, etc.
❖ Ideal for developers using JavaScript, since it uses a similar syntax (JSON).

Key Features of MongoDB:


❖ Document-Oriented: Data is stored as documents (similar to JSON objects).
❖ Schema-Less: Each document can have a different structure—great for flexibility.
❖ Scalable: Supports horizontal scaling through sharding.
❖ High Performance: Optimized for fast reads and writes.
❖ Indexing: Provides powerful indexing features for quick data access.
❖ Aggregation Framework: Allows complex data processing and analysis within the database.

Advantages of MongoDB:
❖ Scalable: Easily handles large volumes of data.
❖ Flexible Schema: Good for agile development and frequent changes.
❖ Speed: Great performance for read/write operations.
❖ Open Source: Free to use with a strong community.
❖ Cross-Platform: Works on Linux, Windows, macOS.

Applications:
❖ Real-time analytics
❖ Social media platforms
❖ Mobile apps
❖ Content management systems (CMS)
❖ E-commerce product catalog
❖ Internet of Things (IoT) apps

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 2

Concepts of MongoDB:

Term Description
Document A single record in MongoDB (stored in BSON format).
Collection A group of MongoDB documents, similar to a table in RDBMS.
Database A container for collections.
Field A key-value pair in a document. Similar to a column in RDBMS.
Index Improves query performance (like indexing in SQL).
Replica Set A group of MongoDB servers that maintain the same data for high availability.
Sharding Distributes data across multiple machines for horizontal scaling.

Code Snippet:
{
"_id": ObjectId("607d1a3a0e3e5f1b6c8b4567"),
"name": "John Doe",
"email": "[email protected]",
"age": 30,
"isVerified": true,
"skills": ["JavaScript", "MongoDB", "Node.js"],
"address": {
"city": "New York",
"zip": "10001"
}
}

Why MongoDB?
MongoDB is used because it is easy to work with, fast, and flexible. It stores data in a format similar to
JSON, which is simple and easy to understand. Unlike traditional databases, it does not require a fixed
structure, so you can change or add data without much trouble. This makes it great for modern apps
where data can often change. MongoDB can also handle large amounts of data and many users at the
same time by spreading the data across different computers. It works well with popular programming
languages and is commonly used in web and mobile app development. Because it is open-source, it’s
free to use and has a big community for help and support.
CRUD stands for Create, Read, Update and Delete are the 4 basic operations you can perform on data.

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 3

MongoDB vs Traditional RDBMS

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 4

Terms Used in RDBMS and MongoDB

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 5

Data Types in MongoDB:


MongoDB data types refer to the different types of data that can be stored in a MongoDB database.
MongoDB supports a wide range of MongoDB data types such as strings, integers, doubles, Booleans,
dates, arrays, object IDs, null and binary data.
In MongoDB, the data type of a field is dynamic, meaning you don't need to declare it explicitly
when you create a document. MongoDB infers the data type based on the value assigned to the field.
However, it's important to be aware of the supported BSON (Binary JSON) data types as they influence
how data is stored, queried, and compared.

1. String:
One of the most basic and widely used data types is the string. To represent text, the string
type is utilized.
Example:
{
"name": "Prasad Patil",
"skills": "Teaching",
"salary": 50,000,
"status": true,
}

2. Integer:
Numeric values are stored using the integer data type. Depending on the server, it can store
32-bit or 64-bit numbers.
Example:
{
"name": "Prasad Patil",
"skills": "Teaching",
"salary": 50,000,
"status": true,
}
salary is of the type integer since it stores a numeric number.

3. Double:
Numeric numbers containing 8 bytes floating-point are stored using the double data type.

Example:
{
"name": "Prasad Patil",
"skills": "Teaching",
"score": 86.67,
"status": true,
}

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 6

4. Boolean:

Boolean (true or false) values are stored with the Boolean data type. The field intern status is
of the type Boolean in the example below because it stores the value true. Booleans take up
less space than integers or strings and avoid unwanted comparison side effects.
Example:
{
"name": "Prasad Patil",
"skills": " Teaching",
"score": 86.67,
"status": true,
}

5. Array:
The array is stored using the array data type. We can store several values in a single key of the
document with an array data type.
Example:
{
" name": "Prasad Patil",
" skills": ["Teaching", "C++", "Java"],
" score": 86.67,
" status": true,
}

6. Object:
An embedded document is a key-value pair that is put inside another document. Embedded
documents are stored using the object data type.
Example:
{
"code": "0000-XYZ",
"price": 39.99,
"dimensions": {
"height": 1000,
"width": 90,
"depth": 600,
},
"availability": true,
}
Because it has its own set of key-value pairs, the product dimensions field in the example above
is an embedded document. As a result, this field is an Object field.

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 7

7. Date:
The current date or time is stored in the ‘Date’ data type. The returning date can be done in a
variety of ways; either a string or a date object. There are three strategies that can be used in this
situation.
1. The Date() function returns a string.
2. Return a date object with New Date().
3. ISODate() returns a date object as well.
Example:
{
" name": "Prasad Patil",
" dob": ISODate("1990-03-08T11:34:42.389Z"),
" marks": 86.67
}

8. Null:
The NULL data type is used to represent a value of zero or no value, as the name implies.
When a null value field in a document is queried, this is what it looks like:
Example
{
"code": "0000-XYZ",
"price": 39.99,
"color": null,
"availability": true,
}

9. Binary
This data type is used in fields to hold binary data. In a relational database management
system, this data type corresponds to the Blob type. Nonetheless, on the grounds that MongoDB has
a report size limitation of 16MB, binary data can be implanted inside a document utilizing the Binary
data type in the event that the full size of the binary data in addition to different fields is under 16MB.
Example
{
"_id": "4567rttyygjuhutfv7890",
"code": "1234-ABCD",
"price": 49.99,
"availability": true,
"picture":BinData(1, "rk56tyvbu5677ghugf456..."),
}

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 8

MongoDB Query Language:


MongoDB uses its own query language called MongoDB Query Language (MQL), which allows users
to interact with the database, perform CRUD operations, and execute aggregations, among other
functionalities.
MQL stands for MongoDB Query Language.
It is the language used to interact with MongoDB databases to perform operations like:
❖ Creating documents
❖ Reading/finding documents
❖ Updating documents
❖ Deleting documents.

Functionality:
❖ CRUD Operations: MQL supports basic CRUD (Create, Read, Update, Delete) operations.
❖ Aggregation: MQL allows users to perform powerful data aggregation operations, such as
filtering, sorting, grouping, and calculating statistics.
❖ Operators: MQL provides various operators to filter, sort, and match documents based on
different criteria.
❖ Flexibility: MQL is designed to be flexible and intuitive, allowing users to express complex
queries efficiently.
How to Use:
❖ MongoDB Shell (mongosh): MQL commands can be executed directly in the MongoDB Shell.
❖ Language Drivers: MQL can be used through language-specific drivers for various
programming languages.
❖ MongoDB Compass: MQL queries can be written and executed in MongoDB Compass, a
graphical user interface for MongoDB.

Common MQL Operators:

Operator Meaning

$gt Greater than

$lt Less than

$eq Equal to

$ne Not equal to

$in Matches any value in an array

$set Set a value

$push Add an item to an array

$inc Increment a field by a number

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.
Big Data Analytics – Unit 2 (Chapter – 5: Big Data Technologies) 9

Examples of MQL in Action:

1. Find Documents (Read)


db.users.find({ age: { $gt: 25 } })

2. Insert a Document (Create)


db.users.insertOne({ name: "Alice", age: 22, city: "Mumbai"})

3. Update a Document
db.users.updateOne({ name: "Alice" }, { $set: { age: 23 } })

4. Delete a Document
db.users.deleteOne({ name: "Alice" })

Why should we use MQL?

❖ Easy to write and read


❖ Powerful for working with documents
❖ Works directly in MongoDB Shell, Compass, or in code (Node.js, Python, etc.)

Prof. Prasad Patil,


Department of Computer Applications,
KLE Tech University, Belagavi.

You might also like