SlideShare a Scribd company logo
1 of 39
MongoDB(from humongous) is a
free and open-source cross-
platform document-oriented
database.Classified as NoSQL
database.
PRACHI VARAIYA
MEAN STACK DEVELOPER
(MONGODB+EXPRESS+ANGULAR+NODEJS)
kalpcorporate
info@kalpcorporate.com
kalpcorporate.com
NoSQL
A form of database management system that is non-relational.
Systems are often schema less,avoid joins and are easy to scale.
A better term would be “NoREL” but NoSQL caught on.Think of it more as meaning
“Not Only SQL”to emphasize that they may support SQL-like query languages.
A NoSQL (originally referring to "non SQL" or "non relational") database provides a
mechanism for storage and retrieval of data which is modeled in means other than
the tabular relations used in relational databases.
But Why Choose NoSQL
● Amount of data stored in internet
e.g.:Facebook is rumoured to hold over 10 TB of data in their NoSql database for
their inbox search.
● The data we stored is more complex than 15 years ago.
● Easy Distribution
● With all this data is needs to be easy to be able to add/remove servers without any
disruption of any service.S
Move To MongoDB -NoSQL Database
MongoDB is an open-source document database that provides high performance, high
availability, and automatic scaling.
It avoids the traditional table-based relational database structure in favor of JSON-like
documents with dynamic schemas (MongoDB calls the format BSON), making the
integration of data in certain types of applications easier and faster.
MongoDB is developed by MongoDB Inc. and is free and open-source, published under
a combination of the GNU Affero General Public License and the Apache License.
As of July 2015, MongoDB was the fourth most widely mentioned database engine on
the web, and the most popular for document stores.
MongoDB BioGraphy
What is MongoDB?
MongoDB is an open source document oriented database. MongoDB falls in the
category of the NoSQL – Database which means it doesn’t follow fixed schema
structure like in relational databases.
MongoDB cannot replace Relational databases but it should be viewed as an
alternative to it. MongoDB can be installed on Windows, Linux and MAC so it is a
cross platform database. It doesn’t support joins but it can represent rich,
hierarchical data structures. And of the best feature the like the most is that it is
easily scalable and can give high performance.
The MongoDB database consists of a set of databases in which each database contains
multiple collections. MongoDB is schema-less what it means is that every collection
can contain different types of object. Every object is also called document which is
represented as a JSON (JavaScript Object Notation) structure: a list of key-value
pairs. The value can be of three types: a primitive value, an array of documents or
Document Database
A record in MongoDB is a document, which is a data structure composed of field and
value pairs. MongoDB documents are similar to JSON objects. The values of fields
may include other documents, arrays, and arrays of documents.
RDBMS VS MongoDB
Query Language in MYSQL Vs MongoDB
MySQL is written using SQL queries, while MongoDB is focused on BSON (Binary JSON).
Key Features
High Performance:
MongoDB provides high performance data persistence. In particular,
Support for embedded data models reduces I/O activity on database system.
Indexes support faster queries and can include keys from embedded documents and arrays.
● Rich Query Language:
MongoDB supports a rich query language to support read and write operations as well as:
Data aggregation
Key Features(Continue...)
High Availability:
MongoDB’s replication facility, called replica set, provides:
automatic failover and
data redundancy.
A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and
increasing data availability.
● Horizontal Scalability:
MongoDB provides horizontal scalability as part of its core functionality:
Sharding distributes data across a cluster of machines.
Getting Started
1. Head over to the official download page and grab the binaries from the first row (the recommended stable
version)
for your operating system of choice. For development purposes, you can pick either 32-bit or 64-bit.
2. Extract the archive (wherever you want) and navigate to the bin subfolder. Don’t execute anything just yet,
but know that mongod is the server process and mongo is the client shell - these are the two executables
we’ll be spending most of our time with.
3. Create a new text file in the bin subfolder named mongodb.config.
4. Add a single line to your mongodb.config:
dbpath=PATH_TO_WHERE_YOU_WANT_TO_STORE_YOUR_DATABASE_FILES
For example, on Windows you might do dbpath=c:mongodbdata and on Linux you might do dbpath=/var/
lib/mongodb/data.
5. Make sure the dbpath you specified exists.
Getting Started (Continue...)
As an example for Windows users, if you extracted the downloaded file to c:mongodb and you created
c:mongodb data then within c:mongodbbinmongodb.config you would specify
dbpath=c:mongodbdata.
You could then launch mongod from a command prompt via c:mongodbbinmongod --config
c:mongodbbinmongodb.config. Feel free to add the bin folder to your path to make all of this less
verbose. MacOSX and Linux users can follow almost identical directions. The only thing you should have to
change are the paths. Hopefully you now have MongoDB up and running.
If you get an error, read the output carefully - the server is quite good at explaining what’s wrong.
You can now launch mongo (without the d) which will connect a shell to your running server. Try entering
db.version() to make sure everything’s working as it should. Hopefully you’ll see the version number you
installed.
The Basics
We begin our journey by getting to know the basic mechanics of working with MongoDB. Obviously this is core to
understanding MongoDB, but it should also help us answer higher-level questions about where MongoDB fits.
To get started, there are six simple concepts we need to understand.
1. A database can have zero or more collections. A collection shares enough in common with a traditional table
that you can safely think of the two as the same thing.
2. Collections are made up of zero or more documents. Again, a document can safely be thought of as a row.
3. A document is made up of one or more fields, which you can probably guess are a lot like columns.
4. Indexes in MongoDB function mostly like their RDBMS counterparts.
5. Cursors are different than the other five concepts but they are important enough, and often overlooked,
that
I think they are worthy of their own discussion. The important thing to understand about cursors is that
when you ask MongoDB for data, it returns a pointer to the result set called a cursor, which we can do things
to, such as counting or skipping ahead, before actually pulling down data.
Databases and Collections
MongoDB stores BSON documents, i.e. data records, in collections; the collections in
databases.
What is BSON(Binary JSON)?
BSON is a binary serialization format used to store documents and make remote
procedure calls in MongoDB. The BSON specification is located at bsonspec.org.
MongoDB represents JSON documents in binary-encoded format called BSON behind
the scenes. BSON extends the JSON model to provide additional data types and to
be efficient for encoding and decoding within different languages.
The MongoDB BSON implementation is lightweight, fast and highly traversable. Like
JSON, MongoDB's BSON implementation supports embedding objects and arrays
within other objects and arrays – MongoDB can even 'reach inside' BSON objects to
build indexes and match objects against query expressions on both top-level and
nested BSON keys. This means that MongoDB gives users the ease of use and
flexibility of JSON documents together with the speed and richness of a lightweight
binary format.
BSON Types
❖BSON supports the following data types as values in documents:
1. ObjectId
2. String
3. Number
4. Date
5. Timestamps
ObjectId
❖ObjectId(<hexadecimal>)
❖Returns a new ObjectId value. The 12-byte ObjectId value consists of:
➢ a 4-byte value representing the seconds since the Unix epoch
➢ a 3-byte machine identifier,
➢ a 2-byte process id, and
➢ a 3-byte counter, starting with a random value.
❖ObjectId() can accept the following parameter:
❖Hexadecimal - (String)-Optional. Hexadecimal string value for the new ObjectId.
String
❖BSON strings are UTF-8. In general, drivers for each programming language convert
from the language’s string format to UTF-8 when serializing and deserializing BSON.
This makes it possible to store most international characters in BSON strings with
ease. In addition, MongoDB $regex queries support UTF-8 in the regex string.
Timestamps
❖BSON strings are UTF-8. In general, drivers for each programming language convert
from the language’s string format to UTF-8 when serializing and deserializing BSON.
This makes it possible to store most international characters in BSON strings with
ease. In addition, MongoDB $regex queries support UTF-8 in the regex string.
❖BSON has a special timestamp type for internal MongoDB use and is not associated
with the regular Date type. Timestamp values are a 64 bit value where:
➢ the first 32 bits are a time_t value (seconds since the Unix epoch)
➢ the second 32 bits are an incrementing ordinal for operations within a given
second.
Date
❖BSON Date is a 64-bit integer that represents the number of milliseconds since the
Unix epoch (Jan 1, 1970). This results in a representable date range of about 290
million years into the past and future.
❖Construct a Date using the new Date() constructor in the mongo shell:
var mydate1 = new Date()
Databases
In MongoDB, databases hold collections of documents.
To select a database to use, in the mongo shell, issue the use <db> statement, as in the
following example:
use myDB
Create a new database:
use mynewDb
db.myNewCollection1.insert( { x: 1 } )
db.myNewCollection1.find()
The insert() operation creates both the database myNewDB and the collection
myNewCollection1 if they do not already exist.
Collections
A grouping of MongoDB documents. A collection is the equivalent of an RDBMS table.
A collection exists within a single database. Collections do not enforce a schema.
Documents within a collection can have different fields. Typically, all documents in a
collection have a similar or related purpose.
Basic syntax of createCollection() command is as follows:
> db.createCollection(name, options)
In the command, name is name of collection to be created. Options is a document and
used to specify configuration of collection
>Name: (String) - Name of the collection to be created
>Options (Document)- (Optional) Specify options about memory size and indexing
Aggregations
Aggregations operations process data records and return computed results.
Aggregation operations group values from multiple documents together, and can
perform a variety of operations on the grouped data to return a single result. In sql
count(*) and with group by is an equivalent of mongodb aggregation.
MongoDB provides three ways to perform aggregation: the aggregation pipeline, the
map-reduce function, and single purpose aggregation methods.
Aggregation Pipeline
MongoDB’s aggregation framework is modeled on the concept of data processing
pipelines. Documents enter a multi-stage pipeline that transforms the documents
into an aggregated result.
The most basic pipeline stages provide filters that operate like queries and document
transformations that modify the form of the output document.
Map-Reduce
MongoDB also provides map-reduce operations to perform aggregation. In general,
map-reduce operations have two phases: a map stage that processes each
document and emits one or more objects for each input document, and reduce
phase that combines the output of the map operation. Optionally, map-reduce can
have a finalize stage to make final modifications to the result. Like other aggregation
operations, map-reduce can specify a query condition to select the input documents
as well as sort and limit the results.
Single Purpose Aggregation Operations
MongoDB also provides db.collection.count(), db.collection.group(),
db.collection.distinct(). special purpose database commands.
Replication
A replica set is a group of mongod instances that maintain the same data set. A replica
set contains several data bearing nodes and optionally one arbiter node. Of the data
bearing nodes, one and only one member is deemed the primary node, while the other
nodes are deemed secondary nodes.
Sharding in MongoDB
MongoDB supports sharding through the configuration of a sharded clusters.
Pros Of MongoDB
Schema less : MongoDB is document database in which one collection holds different different documents.
Number of fields, content and size of the document can be differ from one document to another.
Structure of a single object is clear
No complex joins
Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language
that's nearly as powerful as SQL.
Ease of scale-out: MongoDB is easy to scale
Conversion / mapping of application objects to database objects not needed
Cons Of MongoDB
Data size in MongoDB is typically higher due to e.g. each document has field names stored it
less flexibility with querying (e.g. no JOINs)
No support for transactions - certain atomic operations are supported, at a single document level
At the moment Map/Reduce (e.g. to do aggregations/data analysis) is OK, but not blisteringly fast. So if that's
required, something like Hadoop may need to be added into the mix
Less up to date information available/fast evolving product
Why should use MongoDB
Document Oriented Storage : Data is stored in the form of JSON style documents
Index on any attribute
Replication & High Availability
Auto-Sharding
Rich Queries
Fast In-Place Updates
Professional Support By MongoDB
Where should use MongoDB?
Big Data
Content Management and Delivery
Mobile and Social Infrastructure
User Data Management
Data Hub
Links For MongoDB
https://www.mongodb.com/download-center#community
https://docs.mongodb.com/manual/tutorial/
https://docs.mongodb.org
https://www.mongodb.com/who-uses-mongodb
Our online IM Id’s for more convenient
communication.
3, Suvarna Nagar Bungalow,
Near St.Xaviers School Loyola,
Ahmedabad-380013, Gujarat, India
+91 9879518121
+91 757-294-0388
(001) 415 251 KALP
kalpcorporate
nihar.kalp
nihar@kalpcorporate.com
info@kalpcorporate.com
md@kalpcorporate.com
kalpcorporate.com

More Related Content

What's hot

Mongo db halloween party
Mongo db halloween partyMongo db halloween party
Mongo db halloween partyAndrea Balducci
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node jsHabilelabs
 
MongoDB NYC Python
MongoDB NYC PythonMongoDB NYC Python
MongoDB NYC PythonMike Dirolf
 
Intro to mongo db
Intro to mongo dbIntro to mongo db
Intro to mongo dbChi Lee
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for BeginnersEnoch Joshua
 
CenitHub Presentations | 3- Translator
CenitHub Presentations | 3- TranslatorCenitHub Presentations | 3- Translator
CenitHub Presentations | 3- TranslatorMiguel Sancho
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patternsjoergreichert
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentationMurat Çakal
 
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES IQ Online Training
 
Back to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsBack to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsMongoDB
 
Information Retrieval-4(inverted index_&amp;_query handling)
Information Retrieval-4(inverted index_&amp;_query handling)Information Retrieval-4(inverted index_&amp;_query handling)
Information Retrieval-4(inverted index_&amp;_query handling)Jeet Das
 

What's hot (20)

MongoDb - Details on the POC
MongoDb - Details on the POCMongoDb - Details on the POC
MongoDb - Details on the POC
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongo db halloween party
Mongo db halloween partyMongo db halloween party
Mongo db halloween party
 
Mongo db commands
Mongo db commandsMongo db commands
Mongo db commands
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
MongoDB NYC Python
MongoDB NYC PythonMongoDB NYC Python
MongoDB NYC Python
 
Intro to mongo db
Intro to mongo dbIntro to mongo db
Intro to mongo db
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongodb Introduction
Mongodb Introduction Mongodb Introduction
Mongodb Introduction
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
 
CenitHub Presentations | 3- Translator
CenitHub Presentations | 3- TranslatorCenitHub Presentations | 3- Translator
CenitHub Presentations | 3- Translator
 
Session5 04.evangelos varthis
Session5 04.evangelos varthisSession5 04.evangelos varthis
Session5 04.evangelos varthis
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
 
HTTP1.1/2 overview
HTTP1.1/2 overviewHTTP1.1/2 overview
HTTP1.1/2 overview
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentation
 
Ajax
AjaxAjax
Ajax
 
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES
OVERVIEW OF MONGODB | CREATING USER IN MONGODB & ASSIGNING ROLES
 
Back to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documentsBack to Basics 1: Thinking in documents
Back to Basics 1: Thinking in documents
 
Information Retrieval-4(inverted index_&amp;_query handling)
Information Retrieval-4(inverted index_&amp;_query handling)Information Retrieval-4(inverted index_&amp;_query handling)
Information Retrieval-4(inverted index_&amp;_query handling)
 
02voc
02voc02voc
02voc
 

Similar to Kalp Corporate MongoDB Tutorials

Similar to Kalp Corporate MongoDB Tutorials (20)

Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
Mongo db
Mongo dbMongo db
Mongo db
 
MongoDB.pptx
MongoDB.pptxMongoDB.pptx
MongoDB.pptx
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx
 
Mongodb
MongodbMongodb
Mongodb
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
 
mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
 
Mongodb
MongodbMongodb
Mongodb
 
Mongodb
MongodbMongodb
Mongodb
 
express.pptx
express.pptxexpress.pptx
express.pptx
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
 
nosql [Autosaved].pptx
nosql [Autosaved].pptxnosql [Autosaved].pptx
nosql [Autosaved].pptx
 
express.pdf
express.pdfexpress.pdf
express.pdf
 
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYCHands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
Hands on Big Data Analysis with MongoDB - Cloud Expo Bootcamp NYC
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 
Elasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparisonElasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparison
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

Kalp Corporate MongoDB Tutorials

  • 1. MongoDB(from humongous) is a free and open-source cross- platform document-oriented database.Classified as NoSQL database. PRACHI VARAIYA MEAN STACK DEVELOPER (MONGODB+EXPRESS+ANGULAR+NODEJS) kalpcorporate info@kalpcorporate.com kalpcorporate.com
  • 2. NoSQL A form of database management system that is non-relational. Systems are often schema less,avoid joins and are easy to scale. A better term would be “NoREL” but NoSQL caught on.Think of it more as meaning “Not Only SQL”to emphasize that they may support SQL-like query languages. A NoSQL (originally referring to "non SQL" or "non relational") database provides a mechanism for storage and retrieval of data which is modeled in means other than the tabular relations used in relational databases.
  • 3. But Why Choose NoSQL ● Amount of data stored in internet e.g.:Facebook is rumoured to hold over 10 TB of data in their NoSql database for their inbox search. ● The data we stored is more complex than 15 years ago. ● Easy Distribution ● With all this data is needs to be easy to be able to add/remove servers without any disruption of any service.S
  • 4. Move To MongoDB -NoSQL Database MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. It avoids the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster. MongoDB is developed by MongoDB Inc. and is free and open-source, published under a combination of the GNU Affero General Public License and the Apache License. As of July 2015, MongoDB was the fourth most widely mentioned database engine on the web, and the most popular for document stores.
  • 6. What is MongoDB? MongoDB is an open source document oriented database. MongoDB falls in the category of the NoSQL – Database which means it doesn’t follow fixed schema structure like in relational databases. MongoDB cannot replace Relational databases but it should be viewed as an alternative to it. MongoDB can be installed on Windows, Linux and MAC so it is a cross platform database. It doesn’t support joins but it can represent rich, hierarchical data structures. And of the best feature the like the most is that it is easily scalable and can give high performance. The MongoDB database consists of a set of databases in which each database contains multiple collections. MongoDB is schema-less what it means is that every collection can contain different types of object. Every object is also called document which is represented as a JSON (JavaScript Object Notation) structure: a list of key-value pairs. The value can be of three types: a primitive value, an array of documents or
  • 7.
  • 8. Document Database A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. The values of fields may include other documents, arrays, and arrays of documents.
  • 10. Query Language in MYSQL Vs MongoDB MySQL is written using SQL queries, while MongoDB is focused on BSON (Binary JSON).
  • 11. Key Features High Performance: MongoDB provides high performance data persistence. In particular, Support for embedded data models reduces I/O activity on database system. Indexes support faster queries and can include keys from embedded documents and arrays. ● Rich Query Language: MongoDB supports a rich query language to support read and write operations as well as: Data aggregation
  • 12. Key Features(Continue...) High Availability: MongoDB’s replication facility, called replica set, provides: automatic failover and data redundancy. A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and increasing data availability. ● Horizontal Scalability: MongoDB provides horizontal scalability as part of its core functionality: Sharding distributes data across a cluster of machines.
  • 13. Getting Started 1. Head over to the official download page and grab the binaries from the first row (the recommended stable version) for your operating system of choice. For development purposes, you can pick either 32-bit or 64-bit. 2. Extract the archive (wherever you want) and navigate to the bin subfolder. Don’t execute anything just yet, but know that mongod is the server process and mongo is the client shell - these are the two executables we’ll be spending most of our time with. 3. Create a new text file in the bin subfolder named mongodb.config. 4. Add a single line to your mongodb.config: dbpath=PATH_TO_WHERE_YOU_WANT_TO_STORE_YOUR_DATABASE_FILES For example, on Windows you might do dbpath=c:mongodbdata and on Linux you might do dbpath=/var/ lib/mongodb/data. 5. Make sure the dbpath you specified exists.
  • 14. Getting Started (Continue...) As an example for Windows users, if you extracted the downloaded file to c:mongodb and you created c:mongodb data then within c:mongodbbinmongodb.config you would specify dbpath=c:mongodbdata. You could then launch mongod from a command prompt via c:mongodbbinmongod --config c:mongodbbinmongodb.config. Feel free to add the bin folder to your path to make all of this less verbose. MacOSX and Linux users can follow almost identical directions. The only thing you should have to change are the paths. Hopefully you now have MongoDB up and running. If you get an error, read the output carefully - the server is quite good at explaining what’s wrong. You can now launch mongo (without the d) which will connect a shell to your running server. Try entering db.version() to make sure everything’s working as it should. Hopefully you’ll see the version number you installed.
  • 15. The Basics We begin our journey by getting to know the basic mechanics of working with MongoDB. Obviously this is core to understanding MongoDB, but it should also help us answer higher-level questions about where MongoDB fits. To get started, there are six simple concepts we need to understand. 1. A database can have zero or more collections. A collection shares enough in common with a traditional table that you can safely think of the two as the same thing. 2. Collections are made up of zero or more documents. Again, a document can safely be thought of as a row. 3. A document is made up of one or more fields, which you can probably guess are a lot like columns. 4. Indexes in MongoDB function mostly like their RDBMS counterparts. 5. Cursors are different than the other five concepts but they are important enough, and often overlooked, that I think they are worthy of their own discussion. The important thing to understand about cursors is that when you ask MongoDB for data, it returns a pointer to the result set called a cursor, which we can do things to, such as counting or skipping ahead, before actually pulling down data.
  • 16. Databases and Collections MongoDB stores BSON documents, i.e. data records, in collections; the collections in databases.
  • 17. What is BSON(Binary JSON)? BSON is a binary serialization format used to store documents and make remote procedure calls in MongoDB. The BSON specification is located at bsonspec.org. MongoDB represents JSON documents in binary-encoded format called BSON behind the scenes. BSON extends the JSON model to provide additional data types and to be efficient for encoding and decoding within different languages. The MongoDB BSON implementation is lightweight, fast and highly traversable. Like JSON, MongoDB's BSON implementation supports embedding objects and arrays within other objects and arrays – MongoDB can even 'reach inside' BSON objects to build indexes and match objects against query expressions on both top-level and nested BSON keys. This means that MongoDB gives users the ease of use and flexibility of JSON documents together with the speed and richness of a lightweight binary format.
  • 18. BSON Types ❖BSON supports the following data types as values in documents: 1. ObjectId 2. String 3. Number 4. Date 5. Timestamps
  • 19. ObjectId ❖ObjectId(<hexadecimal>) ❖Returns a new ObjectId value. The 12-byte ObjectId value consists of: ➢ a 4-byte value representing the seconds since the Unix epoch ➢ a 3-byte machine identifier, ➢ a 2-byte process id, and ➢ a 3-byte counter, starting with a random value. ❖ObjectId() can accept the following parameter: ❖Hexadecimal - (String)-Optional. Hexadecimal string value for the new ObjectId.
  • 20. String ❖BSON strings are UTF-8. In general, drivers for each programming language convert from the language’s string format to UTF-8 when serializing and deserializing BSON. This makes it possible to store most international characters in BSON strings with ease. In addition, MongoDB $regex queries support UTF-8 in the regex string.
  • 21. Timestamps ❖BSON strings are UTF-8. In general, drivers for each programming language convert from the language’s string format to UTF-8 when serializing and deserializing BSON. This makes it possible to store most international characters in BSON strings with ease. In addition, MongoDB $regex queries support UTF-8 in the regex string. ❖BSON has a special timestamp type for internal MongoDB use and is not associated with the regular Date type. Timestamp values are a 64 bit value where: ➢ the first 32 bits are a time_t value (seconds since the Unix epoch) ➢ the second 32 bits are an incrementing ordinal for operations within a given second.
  • 22. Date ❖BSON Date is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). This results in a representable date range of about 290 million years into the past and future. ❖Construct a Date using the new Date() constructor in the mongo shell: var mydate1 = new Date()
  • 23. Databases In MongoDB, databases hold collections of documents. To select a database to use, in the mongo shell, issue the use <db> statement, as in the following example: use myDB Create a new database: use mynewDb db.myNewCollection1.insert( { x: 1 } ) db.myNewCollection1.find() The insert() operation creates both the database myNewDB and the collection myNewCollection1 if they do not already exist.
  • 24. Collections A grouping of MongoDB documents. A collection is the equivalent of an RDBMS table. A collection exists within a single database. Collections do not enforce a schema. Documents within a collection can have different fields. Typically, all documents in a collection have a similar or related purpose. Basic syntax of createCollection() command is as follows: > db.createCollection(name, options) In the command, name is name of collection to be created. Options is a document and used to specify configuration of collection >Name: (String) - Name of the collection to be created >Options (Document)- (Optional) Specify options about memory size and indexing
  • 25. Aggregations Aggregations operations process data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result. In sql count(*) and with group by is an equivalent of mongodb aggregation. MongoDB provides three ways to perform aggregation: the aggregation pipeline, the map-reduce function, and single purpose aggregation methods.
  • 26. Aggregation Pipeline MongoDB’s aggregation framework is modeled on the concept of data processing pipelines. Documents enter a multi-stage pipeline that transforms the documents into an aggregated result. The most basic pipeline stages provide filters that operate like queries and document transformations that modify the form of the output document.
  • 27.
  • 28. Map-Reduce MongoDB also provides map-reduce operations to perform aggregation. In general, map-reduce operations have two phases: a map stage that processes each document and emits one or more objects for each input document, and reduce phase that combines the output of the map operation. Optionally, map-reduce can have a finalize stage to make final modifications to the result. Like other aggregation operations, map-reduce can specify a query condition to select the input documents as well as sort and limit the results.
  • 29.
  • 30. Single Purpose Aggregation Operations MongoDB also provides db.collection.count(), db.collection.group(), db.collection.distinct(). special purpose database commands.
  • 31. Replication A replica set is a group of mongod instances that maintain the same data set. A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes.
  • 32. Sharding in MongoDB MongoDB supports sharding through the configuration of a sharded clusters.
  • 33. Pros Of MongoDB Schema less : MongoDB is document database in which one collection holds different different documents. Number of fields, content and size of the document can be differ from one document to another. Structure of a single object is clear No complex joins Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL. Ease of scale-out: MongoDB is easy to scale Conversion / mapping of application objects to database objects not needed
  • 34. Cons Of MongoDB Data size in MongoDB is typically higher due to e.g. each document has field names stored it less flexibility with querying (e.g. no JOINs) No support for transactions - certain atomic operations are supported, at a single document level At the moment Map/Reduce (e.g. to do aggregations/data analysis) is OK, but not blisteringly fast. So if that's required, something like Hadoop may need to be added into the mix Less up to date information available/fast evolving product
  • 35. Why should use MongoDB Document Oriented Storage : Data is stored in the form of JSON style documents Index on any attribute Replication & High Availability Auto-Sharding Rich Queries Fast In-Place Updates Professional Support By MongoDB
  • 36. Where should use MongoDB? Big Data Content Management and Delivery Mobile and Social Infrastructure User Data Management Data Hub
  • 37.
  • 39. Our online IM Id’s for more convenient communication. 3, Suvarna Nagar Bungalow, Near St.Xaviers School Loyola, Ahmedabad-380013, Gujarat, India +91 9879518121 +91 757-294-0388 (001) 415 251 KALP kalpcorporate nihar.kalp nihar@kalpcorporate.com info@kalpcorporate.com md@kalpcorporate.com kalpcorporate.com