You are on page 1of 15

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: https://www.youtube.com/watch?v=MBLbYEKgUwI&t=35s

1. MongoDB Community Server: https://www.mongodb.com/try/download/community


(mongodb-windows-x86_64-7.0.2-signed)

Choose package:
Cont.…
Run MongoDBCompass…………..
Cont.……

YouTube: https://www.youtube.com/watch?v=MBLbYEKgUwI&t=35s

3. MongoDB Database Tools : https://www.mongodb.com/try/download/database-tools

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: https://www.youtube.com/watch?v=MBLbYEKgUwI&t=35s

2. MongoDB Shell : https://www.mongodb.com/try/download/shell


(mongosh-2.0.1-win32-x64.zip)

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:
https://www.youtube.com/watch?v=NLw7Tln6IeM&t=104s

https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/

1. Install Xcode Command-Line Tools


$ xcode-select --install

2. Install Homebrew - https://brew.sh/


$/bin/bash -c "$(curl –fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3. Install MongoDB 7.0 Community Edition


$ brew tap mongodb/brew
$ brew update
$ brew install mongodb-community@7.0

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. db.createCollection ("collection1")
3. show dbs
4. show collections
5. db.dropDatabase()

❖ Write a command to create collection named as busdetails.


1. db.createCollection ("busdetails")
2. db.busdetails.drop() <delete the collection>
3. db.busdetails.insertOne({"id":"1",
"Passenger_name":"Naina","Destination":"Agra"})

4. db.busdetails.insertMany([{"id":"1",
"Passenger_name":"Naina","Destination":"Agra"},{"id":"2", "Passenge_name":"Ankit",
"Destination":"Kanpur" }])

5. db.busdetails.find({$or: [ { Destination: "Agra" }, { Destination:


"Kanpur"} ] })
6. db.busdetails.find().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()

You might also like