SlideShare a Scribd company logo
MONGO DB
A QUICK TUTORIAL ON
VIVEK : uvivek@student.nitw.ac.in 9949350165
INTRODUCTION
SQL DATABASES
▸ Traditional Databases
▸ Relies on fixed table structure with rows, columns and
keys
▸ Data is structured and easier to understand
▸ Examples: MySql, Sqlite, PostgreSQL
INTRODUCTION
SQL VS NOSQL
SQL NOSQL
Relational Databases (RDBMS) Non-relational or distributed database
Table based databases
Document based, key-value pairs, graph
databases or wide-column stores
Predefined schema Dynamic schema for unstructured data
Vertically scalable Both Vertically and Horizontally scalable
Fit for complex query(Standard interface for
performing complex query)
Not fit for complex query(no standard
interface)
Eg : MySql, Oracle, Sqlite, Postgres and MS-SQL
Eg : MongoDB, BigTable, Redis, RavenDb,
Cassandra, Hbase, Neo4j and CouchDb
MONGO DB ?
WHAT IS
MONGO DB
WHAT IS MONGO DB ?
▸ Mongo Db is a document database
▸ Each database contains Collections
▸ Each Collection contains documents
▸ Each Document can have varying number of fields
▸ The size and content of each document can be different
MONGO DB
COMMON TERMS
▸ _id: The _id field is like the document's primary key. If you
create a new document without an _id field, MongoDB
will automatically create the field (24 digit unique
identifier).
▸ Collection: A collection is the equivalent of a table which
is created in any other RDMS such as Oracle or MS SQL
▸ Cursor: This is a pointer to the result set of a query.
Clients can iterate through a cursor to retrieve results
▸ Document: A record in a MongoDB collection is basically
called a document. The document in turn will consist of
field name and values.
MONGODB
COMMON TERMS
▸ Field: A name-value pair in a document. A document has
zero or more fields. Fields are analogous to columns in
relational databases
▸ Database: This is a container for collections like in RDMS
wherein it is a container for tables.
▸ JSON: This is known as JavaScript Object Notation. This is
a human-readable, plain text format for expressing
structured data.
MONGODB
WHY MONGO DB ?
▸ Document Oriented: It is very flexible and adaptable to
real business world situation and requirements. Suitable
for storing large amounts of data
▸ Ad Hoc Queries: Supports searching by field, range
queries, and regular expression searches. Queries can be
made to return specific fields within documents.
▸ Indexing: Indexes can be created to improve the
performance of searches within MongoDB. Any field in a
MongoDB document can be indexed
MONGODB
WHY MONGO DB ?
▸ Replication: MongoDB can provide high availability with
replica sets. A replica set consists of two or more mongo
DB instances. Each replica set member may act in the
role of the primary or secondary replica at any time.
▸ Load Balancing: MongoDB uses the concept of sharding
to scale horizontally by splitting data across multiple
MongoDB instances. MongoDB can run over multiple
servers, balancing the load and/or duplicating data to
keep the system up and running in case of hardware
failure.
MONGO DB
COMMANDS
TIME TO START
COMMANDS
CREATING DATABASE
▸ Use Command is used to create database
▸ If the command is successful you will see the following
use <Database Name>
COMMANDS
CREATING A COLLECTION
▸ The easiest way to create a collection is to insert a record
into a new collection. If the collection is not there it will
be automatically created
▸ If the command is executed successfully
TEXT
INSERT ARRAY INTO MONGO DB
▸ Add more than one record at a time in mongo db
COMMANDS
FIND COMMAND
▸ This command is used to query and find relevant
documents
COMMANDS
UPDATE COMMAND
▸ Update Command is used to update a particular
document
COMMANDS
UPDATE COMMAND
▸ To affect particular fields, we have to use operators such
as $set, $inc, $unset, $rename
COMMANDS
UPDATE COMMAND
▸ Additional properties can be passed. This includes
upsert, multi etc. Each property enables a certain feature
in the update query
COMMANDS
AGGREGATION
▸ Aggregation command is used for grouping based on a
field and finding sum. It is also used to join two
collections
COMMANDS
REMOVE DOCUMENTS FROM COLLECTION
▸ We can remove documents by using remove, deleteOne,
deleteMany.
COMMANDS
DELETE COLLECTION AND DB
▸ We use drop for deleting a collection and dropDatabase
to delete database
CURSORS, USERS,
REPLICATION AND
SHARDING
EXTRA FEATURES OF MONGO
FEATURES
CURSORS
▸ Cursors are pointers to the collections of objects. Using
cursors we can programatically achieve a lot of things.
For example we can iterate and print certain values we
need.
FEATURES
USER ROLES AND AUTHENTICATION
▸ Authentication can be enabled on Mongo Db for security
purposes.
▸ You need to first create an Admin user with role
userAdminAnyDatabase to default admin table.
▸ This admin user can then grant access to other user,
create new users, provide access to certain collections
etc.
FEATURES
REPLICATION
▸ Replication in Mongo is carried out by ReplicaSets
▸ For high availability, mongo allows you replicated your
data across different mongo server.
▸ First you need to start 2 server and specify they belong to
the same replica set.
▸ Log in to one of the servers and add a new replica set
with the ip of the second server. All data will then be
synced and replicated.
FEATURES
SHARDING
▸ There are two forms of scaling
vertical and horizontal
▸ Mongo supports horizontal
scaling by splitting the load
between different replica sets.
▸ Three main components are
present: Router server, Config
server and the shard servers
THANK YOU

More Related Content

PPTX
Introduction to mongoose and mongodband others
PPTX
How to learn MongoDB for beginner's
PPT
Mongo Bb - NoSQL tutorial
PPTX
The Basics of MongoDB
PDF
monfodb for full stack programmers good.
PDF
Mongodb
PPTX
NoSQL and MongoDB
PPTX
Mongodb - NoSql Database
Introduction to mongoose and mongodband others
How to learn MongoDB for beginner's
Mongo Bb - NoSQL tutorial
The Basics of MongoDB
monfodb for full stack programmers good.
Mongodb
NoSQL and MongoDB
Mongodb - NoSql Database

Similar to MongoDbPpt based on python installation. (20)

PPTX
Introduction to NoSql
PPTX
Klevis Mino: MongoDB
PDF
MongoDB is the MashupDB
PPTX
mongodb11 (1) (1).pptx
PPTX
MongoDB - A next-generation database that lets you create applications never ...
PPTX
Azure cosmos db, Azure no-SQL database,
PPTX
PPTX
MongoDB for the SQL Server
PDF
MongoDB in Simple and Easy Steps
PPTX
NOSQL and MongoDB Database
PDF
Introduction to mongo db
PDF
Mongo db transcript
PPTX
Mongo db
PPTX
MongoDB using Grails plugin by puneet behl
PDF
mongodb tutorial
PDF
SQL vs NoSQL, an experiment with MongoDB
PPTX
Introduction to No SQL - Learn nosql databases
PDF
MongoDB NoSQL database a deep dive -MyWhitePaper
PPTX
Mongodb vs mysql
PPTX
MongoDB introduction features -presentation - 2.pptx
Introduction to NoSql
Klevis Mino: MongoDB
MongoDB is the MashupDB
mongodb11 (1) (1).pptx
MongoDB - A next-generation database that lets you create applications never ...
Azure cosmos db, Azure no-SQL database,
MongoDB for the SQL Server
MongoDB in Simple and Easy Steps
NOSQL and MongoDB Database
Introduction to mongo db
Mongo db transcript
Mongo db
MongoDB using Grails plugin by puneet behl
mongodb tutorial
SQL vs NoSQL, an experiment with MongoDB
Introduction to No SQL - Learn nosql databases
MongoDB NoSQL database a deep dive -MyWhitePaper
Mongodb vs mysql
MongoDB introduction features -presentation - 2.pptx
Ad

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Institutional Correction lecture only . . .
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
RMMM.pdf make it easy to upload and study
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Classroom Observation Tools for Teachers
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Business Ethics Teaching Materials for college
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
VCE English Exam - Section C Student Revision Booklet
Institutional Correction lecture only . . .
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Final Presentation General Medicine 03-08-2024.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Insiders guide to clinical Medicine.pdf
Microbial diseases, their pathogenesis and prophylaxis
STATICS OF THE RIGID BODIES Hibbelers.pdf
Week 4 Term 3 Study Techniques revisited.pptx
Complications of Minimal Access Surgery at WLH
RMMM.pdf make it easy to upload and study
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Classroom Observation Tools for Teachers
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Business Ethics Teaching Materials for college
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
Ad

MongoDbPpt based on python installation.

  • 1. MONGO DB A QUICK TUTORIAL ON VIVEK : uvivek@student.nitw.ac.in 9949350165
  • 2. INTRODUCTION SQL DATABASES ▸ Traditional Databases ▸ Relies on fixed table structure with rows, columns and keys ▸ Data is structured and easier to understand ▸ Examples: MySql, Sqlite, PostgreSQL
  • 3. INTRODUCTION SQL VS NOSQL SQL NOSQL Relational Databases (RDBMS) Non-relational or distributed database Table based databases Document based, key-value pairs, graph databases or wide-column stores Predefined schema Dynamic schema for unstructured data Vertically scalable Both Vertically and Horizontally scalable Fit for complex query(Standard interface for performing complex query) Not fit for complex query(no standard interface) Eg : MySql, Oracle, Sqlite, Postgres and MS-SQL Eg : MongoDB, BigTable, Redis, RavenDb, Cassandra, Hbase, Neo4j and CouchDb
  • 5. MONGO DB WHAT IS MONGO DB ? ▸ Mongo Db is a document database ▸ Each database contains Collections ▸ Each Collection contains documents ▸ Each Document can have varying number of fields ▸ The size and content of each document can be different
  • 6. MONGO DB COMMON TERMS ▸ _id: The _id field is like the document's primary key. If you create a new document without an _id field, MongoDB will automatically create the field (24 digit unique identifier). ▸ Collection: A collection is the equivalent of a table which is created in any other RDMS such as Oracle or MS SQL ▸ Cursor: This is a pointer to the result set of a query. Clients can iterate through a cursor to retrieve results ▸ Document: A record in a MongoDB collection is basically called a document. The document in turn will consist of field name and values.
  • 7. MONGODB COMMON TERMS ▸ Field: A name-value pair in a document. A document has zero or more fields. Fields are analogous to columns in relational databases ▸ Database: This is a container for collections like in RDMS wherein it is a container for tables. ▸ JSON: This is known as JavaScript Object Notation. This is a human-readable, plain text format for expressing structured data.
  • 8. MONGODB WHY MONGO DB ? ▸ Document Oriented: It is very flexible and adaptable to real business world situation and requirements. Suitable for storing large amounts of data ▸ Ad Hoc Queries: Supports searching by field, range queries, and regular expression searches. Queries can be made to return specific fields within documents. ▸ Indexing: Indexes can be created to improve the performance of searches within MongoDB. Any field in a MongoDB document can be indexed
  • 9. MONGODB WHY MONGO DB ? ▸ Replication: MongoDB can provide high availability with replica sets. A replica set consists of two or more mongo DB instances. Each replica set member may act in the role of the primary or secondary replica at any time. ▸ Load Balancing: MongoDB uses the concept of sharding to scale horizontally by splitting data across multiple MongoDB instances. MongoDB can run over multiple servers, balancing the load and/or duplicating data to keep the system up and running in case of hardware failure.
  • 11. COMMANDS CREATING DATABASE ▸ Use Command is used to create database ▸ If the command is successful you will see the following use <Database Name>
  • 12. COMMANDS CREATING A COLLECTION ▸ The easiest way to create a collection is to insert a record into a new collection. If the collection is not there it will be automatically created ▸ If the command is executed successfully
  • 13. TEXT INSERT ARRAY INTO MONGO DB ▸ Add more than one record at a time in mongo db
  • 14. COMMANDS FIND COMMAND ▸ This command is used to query and find relevant documents
  • 15. COMMANDS UPDATE COMMAND ▸ Update Command is used to update a particular document
  • 16. COMMANDS UPDATE COMMAND ▸ To affect particular fields, we have to use operators such as $set, $inc, $unset, $rename
  • 17. COMMANDS UPDATE COMMAND ▸ Additional properties can be passed. This includes upsert, multi etc. Each property enables a certain feature in the update query
  • 18. COMMANDS AGGREGATION ▸ Aggregation command is used for grouping based on a field and finding sum. It is also used to join two collections
  • 19. COMMANDS REMOVE DOCUMENTS FROM COLLECTION ▸ We can remove documents by using remove, deleteOne, deleteMany.
  • 20. COMMANDS DELETE COLLECTION AND DB ▸ We use drop for deleting a collection and dropDatabase to delete database
  • 22. FEATURES CURSORS ▸ Cursors are pointers to the collections of objects. Using cursors we can programatically achieve a lot of things. For example we can iterate and print certain values we need.
  • 23. FEATURES USER ROLES AND AUTHENTICATION ▸ Authentication can be enabled on Mongo Db for security purposes. ▸ You need to first create an Admin user with role userAdminAnyDatabase to default admin table. ▸ This admin user can then grant access to other user, create new users, provide access to certain collections etc.
  • 24. FEATURES REPLICATION ▸ Replication in Mongo is carried out by ReplicaSets ▸ For high availability, mongo allows you replicated your data across different mongo server. ▸ First you need to start 2 server and specify they belong to the same replica set. ▸ Log in to one of the servers and add a new replica set with the ip of the second server. All data will then be synced and replicated.
  • 25. FEATURES SHARDING ▸ There are two forms of scaling vertical and horizontal ▸ Mongo supports horizontal scaling by splitting the load between different replica sets. ▸ Three main components are present: Router server, Config server and the shard servers