0% found this document useful (0 votes)
6 views

Introduction to MongoDB

The document provides an introduction to MongoDB, highlighting its features such as auto sharding, replication, and a rich query language, which address challenges faced by traditional relational databases. It explains the structure of MongoDB, including databases, collections, and documents, and emphasizes its support for dynamic queries and binary data storage. Additionally, it covers key concepts like unique identifiers, data redundancy through replication, and horizontal scaling via sharding.

Uploaded by

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

Introduction to MongoDB

The document provides an introduction to MongoDB, highlighting its features such as auto sharding, replication, and a rich query language, which address challenges faced by traditional relational databases. It explains the structure of MongoDB, including databases, collections, and documents, and emphasizes its support for dynamic queries and binary data storage. Additionally, it covers key concepts like unique identifiers, data redundancy through replication, and horizontal scaling via sharding.

Uploaded by

pradeepn
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/ 38

Introduction to MongoDB

Introduction
● Relational database has prevailed for many decades
● A new type of enterprise database is gaining ground is NoSQL (Not only SQL)
● Focus of the chapter is MongoDB
● Various features of MongoDB are discussed - Auto sharding, replication, rich
query language, fast in-place update, etc.
● CRUD (Create, Read, Update, Delete)
What is MongoDB
Why MongoDB?
● Few challenges of relational database:
○ Is dealing with high volume of data.
○ Rich variety of data - particularly unstructured data, and
○ Meeting up to the scale needs of enterprise data
● The need for
○ Scale out or scale horizontally to meet scale enterprise data
○ High flexibility w.r.t schema
○ Fault tolerant
○ Distributed over multi node of nodes in a cluster
Why MongoDB?
Why MongoDB?
● MongoDB uses BSON (Binary JSON)
● CSV -> XML -> JSON
● CSV:
Why MongoDB?
● As there are multiple values for a attribute, it becomes messy in .CSV
● XML is highly extensible.
● It just does not call for defining data format, rather than how do you define a
data format.
● However, you may be prepared for cumbersome task for highly complex and
structured data.
● JSON is very expressive
● In JSON, Ease to store and retrieve documents
Why MongoDB?
Creating or generating unique key
● Each JSON document is unique identifier (the _id key)
● It is similar to primary key in relational databases
● Based on unique identifier documents were searched
● An index is automatically built on the unique identifier
● Unique identifier either create by yourself or automatically generated
Terms used in MongoDB
● Database: Collection of collection. Container for collection. Each database
gets its own files on file system. Single MongoDB server hosts multiple
databases
● Collection: similar to tables in RDBMS
● Document: It is similar to row/record/tuple
Support for dynamic query
● MongoDB has extensive support for dynamic queries
● RDBMS support for static data and dynamic query
● CoughDB, dynamic data and static queries
Storing binary data
● MongoDB provides GridFS to support the storage of binary data.
● It can store upto 4 MB
● It suffices for photographs or small audio clips
● To store movie clips, MongoDB has another solutions
● It stores metadata in collection called “file”
Replication
● Supports data redundancy and high availabality
● It helps recovery from hardware failure and service interruptions.
● MongoDB supports one primary and several secondary
● Each write requests directed to primary and written in the Oplogs.
● The Oplog is used by secondaries to synchronize their data.
● Thereby strict consistency is achieved by primary and secondaries.
Replication
Sharding
● It is similar to horizontal scaling
● A large data set is divided and distributed over multiple servers or shards.
● The primary advantage of shards are as follows:
● Sharding reduces amount of data on each shards
● Sharding reduces number of operations on each shard.
Sharding
Terms used in RDBMS and MongoDB
Terms used in RDBMS and MongoDB
Creating database
Creating database (...cont)
Dropping database
Data types in MongoDB
Databases in MongoDB
Databases in MongoDB
Databases in MongoDB
CRUD operation
CRUD operation
CRUD operation
MongoDB Query Language
Creating collection
● To display collection in current Database:
● Show collections

Dropping collection
Insert Method
Dealing with collection
Dealing with collection
Dealing with collection
Dealing with collection
Dealing with collection
Dealing with collection

You might also like