0% found this document useful (0 votes)
4 views14 pages

MONGODB

The document discusses NoSQL databases, specifically MongoDB, highlighting its flexible, document-oriented data model that allows for unstructured data storage without predefined schemas. It contrasts NoSQL with traditional relational databases (RDBMS), emphasizing advantages such as better scalability for big data and lower management costs. Key differences between MongoDB and SQL include data storage formats, relationship handling, and schema requirements.

Uploaded by

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

MONGODB

The document discusses NoSQL databases, specifically MongoDB, highlighting its flexible, document-oriented data model that allows for unstructured data storage without predefined schemas. It contrasts NoSQL with traditional relational databases (RDBMS), emphasizing advantages such as better scalability for big data and lower management costs. Key differences between MongoDB and SQL include data storage formats, relationship handling, and schema requirements.

Uploaded by

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

NoSQL and

MongoDB

1
"Imagine a database where you
don’t have to define your table
structure in advance, and you
can store any kind of data—text,
numbers, arrays, even nested
objects—in a single record. How
would this change the way you
design or scale your applications
3
MongoDB
 MongoDB is a powerful, open-source NoSQL
database that offers a document-oriented data
model, providing a flexible alternative to
traditional relational databases. Unlike SQL
databases, MongoDB stores data in BSON
format, which is similar to JSON, enabling
efficient and scalable data storage and retrieval.
What is NoSQL?
•Not only SQL
•SQL means
 Relational model
 Strong typing
 ACID compliance
 Normalization
…
•NoSQL means more freedom or
flexibility
5
Relevance to Big Data
•Data gets bigger
•Traditional RDBMS cannot scale well
•RDBMS is tied to its data and
query processing models
•NoSQL relaxes some of the
restrictions of RDBMS to provide a
better performance

6
Advantages of NoSQL
•Handles Big Data
•Data Models – No predefined schema
•Data Structure – NoSQL handles semi-
structured data
•Cheaper to manage
•Scaling – Scale out / horizonal scaling

7
Advantages of RDBMS
•Better for relational data
•Data normalization
•Well-established query language (SQL)
•Data Integrity
•ACID Compliance

8
Structured/Semi-structured

ID Name Email …

1 Jack [email protected]

2 Jill [email protected]

3 Alex [email protected]

Document 1

{ “id”: 1, “name”:”Jack”, “email”: “[email protected]”,


Document 2
“address”: {“street”: “900 university ave”, “city”: “Riv erside”,
state: “CA”}, “friend_ids”: [3, 55, 123]}
{ “id”: 2, “name”: “Jill”, “email”: “[email protected]”, “hobbies”:
[“hiking”, “cooking”]}

9
Document Data
Model
•Relational model (RDBMS)
 Database
o
Relation (Table) : Schema
- Record (Tuple) : Data
•Document Model Document 1
{ “id”: 1, “name”:”Jack”, “email”: “[email protected]”,

 Database “address”: {“street”: “900 university ave”, “city”: “Riverside”,


state: “CA”}, “friend_ids”: [3, 55, 123]}

o
Collection : No predefined schema
- Document : Schema+data
•No need to define/update schema
•No need to create collections
10
Document Format
•MongoDB natively works with JSON
documents
•For efficiency, documents are stored in a
binary format called BSON (i.e., binary
JSON)
•Like JSON, both schema and data are
stored in each document

11
How to Use MongoDB
Install: Check the MongoDB website
https://docs.mongodb.com/manual/installation/
Create collection and insert a document
db.users.insert({name: “Jack”,
email: “[email protected]”});
Retrieve all/some documents
db.users.find();
db.users.find({name:
“Jack”});
Update
db.users.update({name: "Jack"}, {$set:
{hobby: "cooking"}});
updateOne, updateMany,
replaceOne
Delete
db.users.remove({name: "Alex"});
deleteOne,
deleteMany 13
https://docs.mongodb.com/manual/crud/
Key Difference between MongoDB & SQL
MySQL
MongoDB

SQL, supports structured data with


Paradigm NoSQL, supports unstructured data
schemas

Data Storage Collections containing JSON documents Tables with rows and columns

Supports relationships with foreign keys


Relationships No support for table relationships
and primary keys

Data Model Non-relational Relational

Scalability Supports horizontal scaling (sharding) Supports vertical scaling

Reliability and Architecture moved towards distributed


Built for resilience and availability
Availability databases for reliability

Predefined schema required for data


Schema No predefined schema, dynamic structure
structure

Limited document querying, no support Uses SQL for querying and advanced
Query Language
for joins analytics functions
Post Lecture Assessment

You might also like