Unit 5 - Chapter 2 - Introduction To MongoDB
Unit 5 - Chapter 2 - Introduction To MongoDB
https://www.educba.com/what-is-mongodb/
Where to Use MongoDB?
• Big Data
• Content Management and Delivery
• Mobile and Social Infrastructure
• User Data Management
• Data Hub
The following table shows the relationship of RDBMS terminology with
MongoDB.
RDBMS MongoDB
Database Database
Table Collection
Tuple/Row Document
Column Field
• Note: In MongoDB default database is test. If you didn't create any database, then
collections will be stored in test database.
• Drop database
• To drop the database execute following command, this will drop the selected database
>db.dropDatabase()
• Create collection
To create the new collection execute the following commands
>db.createCollection(name)
Eg:db.createCollection(“Employee”)
• Drop collection
• Delete
• remove permanently deletes documents from the database
>db.post.remove({“title”:…..})
Check back the collection
Basic commands
• MongoDB use DATABASE_NAME is used to create database. The command will
create a new database if it doesn't exist, otherwise it will return the existing
database.
• Syntax use DATABASE_NAME
• Basic syntax of use DATABASE statement is as follows −
> use mydb
• To check your currently selected database, use the command
>db
• If you want to check your databases list, use the command
>show dbs.
• Creating document in the database area
>db.movie.insert({“name”: “KHNH”})
• Note: In MongoDB default database is test. If you didn't create any database, then
collections will be stored in test database.
• Drop database
• To drop the database execute following command, this will drop the selected database
>db.dropDatabase()
• Create collection
To create the new collection execute the following commands
>db.createCollection(name)
Eg:db.createCollection(“Employee”)
• https://docs.mongodb.com/manual/reference/method/db.createCollection/
• Drop collection