Mongodb Documentation
Mongodb Documentation
MONGODB
Difference Between Structured Query Language (SQL) and Unstructured Query Language (NoSQL)
Query Uses SQL for querying (SELECT, Uses various query methods (e.g., JSON-like
Language INSERT, UPDATE, DELETE). queries in MongoDB, CQL in Cassandra).
Rigid schema; changes require Dynamic schema; data fields can vary across
Schema
altering tables. records.
Best for structured data like financial Best for unstructured/semi-structured data like
Use Cases records, customer databases, and social media, IoT, big data, and real- me
transac onal systems. applica ons.
Conclusion
SQL databases are ideal for applica ons requiring structured data, consistency, and complex
transac ons.
NoSQL databases are suitable for highly scalable, flexible, and big data applica ons.
This documenta on provides a structured guide on using MongoDB commands for database
management, collec on opera ons, and document manipula on.
Default databases include:
admin
config
local
show dbs
use <database_name>
If the database does not exist, MongoDB creates it when a collec on is added.
db.getName()
db.<collec on_name>.drop()
db.<collec on_name>.insertOne({
favourite_food: "pizza"
})
db.<collec on_name>.insertMany([
])
db.<collec on_name>.find()
db.employees.updateOne(
{ name: "Willy" },
{ name: "Phob" },
db.employees.updateMany(
{ age: { $lt: 30 } },
4. Dele ng Documents
db.employees.find().sort({ name: 1 })
db.employees.find().sort({ name: -1 })
db.employees.updateMany(
{ "home": { $lt: 10 } },
{ $inc: { "bonus": 15 } }