NoSQL
RDBMS V/S NOSQL
SQL NoSQL
Relational Database Management System (RDBMS) Non-relational or distributed database system.
These databases have fixed or static or predefined schema They have dynamic schema
Vertically Scalable Horizontally scalable
Follows ACID property Follows BASE property
RDBMS V/S NOSQL
RDBMS MongoDB
Database Database
Table Collection
Row Document
Column Field
How to Install Latest MongoDB on Windows
YouTube: [Link]
1. MongoDB Community Server: [Link]
(mongodb-windows-x86_64-7.0.2-signed)
Choose package:
Cont.…
Run MongoDBCompass…………..
Cont.……
YouTube: [Link]
3. MongoDB Database Tools : [Link]
Choose package:
Cont.…
C:\Program Files\MySQL\MySQL Server 8.0\bin
C:\Program Files\MongoDB\Tools\100\bin
D:\OneDrive - BENNETT UNIVERSITY\Desktop\mongosh-2.0.1-win32-x64\bin
Cont.……
YouTube: [Link]
2. MongoDB Shell : [Link]
([Link])
Choose package:
Cont.…
C:\Program Files\MySQL\MySQL Server 8.0\bin
C:\Program Files\MongoDB\Tools\100\bin
D:\OneDrive - BENNETT UNIVERSITY\Desktop\mongosh-2.0.1-win32-x64\bin
How to Install Latest MongoDB on macOS
YouTube:
[Link]
[Link]
1. Install Xcode Command-Line Tools
$ xcode-select --install
2. Install Homebrew - [Link]
$/bin/bash -c "$(curl –fsSL [Link]
3. Install MongoDB 7.0 Community Edition
$ brew tap mongodb/brew
$ brew update
$ brew install
[email protected]4. Run MongoDB
$ brew services start mongodb/brew/mongodb-community
5. Connect and use MongoDB
$ mongosh
❖ Create new database “abc”. Create a new collection of names “collection1”. Show all databases
1. use abc
2. [Link] ("collection1")
3. show dbs
4. show collections
5. [Link]()
❖ Write a command to create collection named as busdetails.
1. [Link] ("busdetails")
2. [Link]() <delete the collection>
3. [Link]({"id":"1",
"Passenger_name":"Naina","Destination":"Agra"})
4. [Link]([{"id":"1",
"Passenger_name":"Naina","Destination":"Agra"},{"id":"2", "Passenge_name":"Ankit",
"Destination":"Kanpur" }])
5. [Link]({$or: [ { Destination: "Agra" }, { Destination:
"Kanpur"} ] })
6. [Link]().pretty()
db.List_Buses.insertMany([
{ bus_number: 1, bus_name: "Bus1", source: "Pari Chauk", destination: "Bennett", available_days: ["Monday",
"Wednesday", "Friday"] },
{ bus_number: 2, bus_name: "Bus2", source: "Delhi", destination: "Agra", available_days: ["Tuesday",
"Thursday", "Saturday"] }
])
Display all buses available between a specific source and destination on a particular day.
db.List_Buses.find({ source: "Source1", destination: "Destination1", available_days: "Monday" })
Find buses that operate on Monday and Wednesday.
db.List_Buses.find({ available_days: { $all: ["Monday", "Wednesday"] } })
Update the name of a bus with bus number 2 to Delux.
db.List_Buses.updateOne(
{ bus_number: 2 },
{ $set: { bus_name: "Delux" } }
)
Remove a bus number2 from the collection Buses.
db.List_Buses.deleteOne({ bus_number: 2 })
Count the total number of buses in the collection.
db.List_Buses.countDocuments()