Mongodb: A complete guide about MongoDB, MongoDB with Node JS, Mongodb Replication and shading concept
Mongo DB |
1. Overview of MongoDB
- Queries: It supports ad-hoc queries and document-based queries.
- Index Support: Any field in the document can be indexed.
- Replication: It supports Master-Slave replication. MongoDB uses a native application
- to maintain multiple copies of data. Preventing database downtime is one of the replica set’s features as it has self-healing shards.
- Multiple Servers: The database can run over multiple servers. Data is duplicated to
- foolproof the system in the case of hardware failure.
- Auto-shading: This process distributes data across multiple physical partitions
- called shards. Due to shading, MongoDB has an automatic load balancing feature.
- MapReduce: It supports MapReduce and flexible aggregation tools.
- Failure Handling: In MongoDB, it’s easy to cope with cases of failures.
- Huge numbers of replicas give out increased protection and data availability
- against database downtime like rack failures, multiple machine failures, and
- data center failures, or even network partitions.
- GridFS: Without complicating your stack, any sizes of files can be stored.
- GridFS feature divides files into smaller parts and stores them as separate documents.
- Schema-less Database: It is a schema-less database written in C++.
- Document-oriented Storage: It uses BSON format which is a JSON-like format.
- Procedures: MongoDB JavaScript works well as the database
- uses the language instead of procedures.
2. What is MongoDB?
- MongoDB is a document-oriented database that stores data in JSON-like documents with the dynamic schema. It means you can store your records without worrying about the data structure such as the number of fields or types of fields to store values. MongoDB documents are similar to JSON objects.
-
MongoDB is one of the most popular open-source NoSQL database written in C++. As of February 2015, MongoDB is the fourth most popular database management system.
3. Right Audience to Learn MongoDB
- Beginners - Basic Computer Background | Science Background | Arts Background
- Bachelor of Computer Application - Background Students
- Master of Computer Application - Background Students
- PHD in Computer Science - Background Students
- Data Analyst - Any Experience level
- Web Developer - Any technology
- Full Stack Engineer - Any Experience level
- Full Stack Technical Architect
- Web Analyst
4. How will this technology help you in your career growth 2019-2020?
Popularity of MongoDB |
5. How MongoDB Documents looks like ?
MongoDB Documents Looks Like |
6. How MongoDB stores the data?
How MongoDB Store the Data |
7. Why and Where we need to use MongoDB?
- MongoDB is good for the E-Commerce type of project, also its good for blog and content management.
- Social Networking Site.
- Oil industry, where we are having the scenario to deal with large number of database.
8. MongoDB Supports Languages
- C, C++, C#, .Dot net
- Java, PHP, Node JS
- It also supports perl python and Rubi.
9. Popular Company's are using MongoDB
- MICROSOFT, RED HAT, ADOBE, BOSCH
- HIKE, EBAY, EA, LINKED IN, MTV, SAP, ZENDISK E.T.C
- CISCO, SONY, IBM
- CITRIX, FACEBOOK, HTC, GOOGLE, TWITTER
10. Installation of MongoDB and RobotT for MongoDB data visualization
11. Inserting data into MongoDB
Insert One
for(var i =1;i<=10000;i++){db.employee.insertOne( { emp_id:i, name: "atique", age: i+10,dept:”IT”, skills: ["nodejs", “angular”,”mongodb”,”ElasticSearch”], leaves: { CL: 10, SL: 10, PL: 21 } })}
Insert Many
db.employee.insertMany([
{ id:”120”, name: "sunny", dept:”Testing”, skills: ["jira", “mentis bug tracking tool”], leaves: { CL: 10, SL: 10, PL: 21 } },
{ id:”122”, name: "sonu", dept:”IT”, skills: ["nodejs", “angular”,”mongodb”,”ElasticSearch”], leaves: { CL: 10, SL: 10, PL: 21 } },
{ id:”120”, name: "sunny", dept:”Testing”, skills: ["jira", “mentis bug tracking tool”], leaves: { CL: 10, SL: 10, PL: 21 } },
{ id:”122”, name: "sonu", dept:”IT”, skills: ["nodejs", “angular”,”mongodb”,”ElasticSearch”], leaves: { CL: 10, SL: 10, PL: 21 } },
{ id:”123”, name: "rubi", dept:”IT frontend”, skills: ["html", “css”,”angularjs”,”vue js”], leaves: { CL: 10, SL: 10, PL: 21 } }
{ id:”123”, name: "rubi", dept:”IT frontend”, skills: ["html", “css”,”angularjs”,”vue js”], leaves: { CL: 10, SL: 10, PL: 21 } }
])
])
for(var i =1;i<=10000;i++){db.employee.insertOne( { emp_id:i, name: "atique", age: i+10,dept:”IT”, skills: ["nodejs", “angular”,”mongodb”,”ElasticSearch”], leaves: { CL: 10, SL: 10, PL: 21 } })}
Insert Many
db.employee.insertMany([
{ id:”120”, name: "sunny", dept:”Testing”, skills: ["jira", “mentis bug tracking tool”], leaves: { CL: 10, SL: 10, PL: 21 } },
{ id:”122”, name: "sonu", dept:”IT”, skills: ["nodejs", “angular”,”mongodb”,”ElasticSearch”], leaves: { CL: 10, SL: 10, PL: 21 } },
12. Updating data into MongoDB
Update
db.student.update({"empid" : 42},{$set: { "dept" : "HR"}}); )
db.student.updateOne({'dept':'HRA'}, {$set: {'dept':'IT'}})
Replace One
13. Deleting data from MongoDB
Delete One
Delete Many
db.student.deleteMany({'dept':'business'})
14. MongoDB Projection, Find, And Or
Projection or Find
Or
db.getCollection('employee').find({ $or: [ { age: { $gt: 40 }}, { emp_id: { $gt: 10}} ] }).count()
And
db.getCollection('employee').find({ $and: [ { age: { $gt: 40 }},
{emp_id: { $gt: 10 }} ] }.count()
15. MongoDB Sort, Count, Skip & Limit
db.getCollection('customercomplaints').find().sort({'email':-1}) //Descending Order
Count
db.getCollection('employee').find({}).count()
Skip and Limit
db.getCollection('customercomplaints').find().skip(1).limit(2).forEach(printjson);
More Details and practical example please visit the below video link -
16. What is MongoDB Indexing?
db.employee.insert({'emp_id':NumberInt(i+1), age: NumberInt(i+10), dept: "IT", Skills: ["Nodejs","Angular7","Elasticsearch"])
}
Ensure Index
db.collectionname.ensureIndex({"employeeId":1})
Drop Index
db.collectionName.dropIndex({"employeeId":1})
More Details & practical example please watch the below video link -
17. What is MongoDB Aggregation?
DB.db.school.aggregate([{$group : {_id : "$gender", myreport: {$sum: NumberInt(1)}}}])db.school.aggregate([{$group : {_id : "$gender", myreport: {$max: "$age"}}}])db.school.aggregate([{$group : {_id : "$gender", myreport: {$min: "$age"}}}])
18. What is MongoDB Replication?
Replication is the process of synchronizing data across multiple servers. Replication provides redundancy and increases data availability with multiple copies of data on different
19. How MongoDB Replication perform?
Mongodb Replication |
20. What is MongoDB Sharding ?
Mongodb sharding |
21. How MongoDB Sharding works?
How Mongodb sharding Works |
22. What MongoDB Backup and Restore?
# Mongodb Backup and Restore
Go to your terminal -- >
1. mongod
2. Open robotT to check the connection
# Mongodb dumping entire all database and Restore
2. delete all the database from roboT
1. mongodump --db mongodbTutorial
2. delete database mongodb Tutorail from RoboT || db.databaseName.drop()
3. mongorestore
# Mongodb dumping single collection and Restore single collection
1. mongodump --db mongodbTutorial --collection school
2. delete the collection from the perticular database from roboT || db.collectionName.drop()
3. mongorestore --db mongodbTutorial --collection school dump/mongodbTutorial/school.bson
More Details & practical example please watch the below video link -
23. MongoDB with Node JS Followed by MVC Architecture?
db.js
const mongoose = require('mongoose')
const config=require('config');
mongoose.connect(config.mongodb.url+''+config.mongodb.local_server_ip+':'+config.mongodb.port+'/'+config.mongodb.databaseName,{ useNewUrlParser:true, useUnifiedTopology: true },(err) => {if(!err){console.log('MongoDB connected...')} else{console.log('Error in DB connection: ' + JSON.stringify(err, undefined, 2) );}})
0 comments :
Post a Comment