0% found this document useful (0 votes)
38 views

MongoDB Tutorial ?

This document provides an overview of MongoDB, including: - MongoDB is a document-oriented NoSQL database written in C++. - Data is organized into databases, collections of documents, and individual documents which can have varying fields. - The basics of installing, starting, and accessing MongoDB are explained, along with commands for creating databases and collections, inserting, querying, updating, and deleting data. - Features like indexing, logical operators, data types, and advantages over relational databases are also summarized.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

MongoDB Tutorial ?

This document provides an overview of MongoDB, including: - MongoDB is a document-oriented NoSQL database written in C++. - Data is organized into databases, collections of documents, and individual documents which can have varying fields. - The basics of installing, starting, and accessing MongoDB are explained, along with commands for creating databases and collections, inserting, querying, updating, and deleting data. - Features like indexing, logical operators, data types, and advantages over relational databases are also summarized.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

#tutorial Save & Share

Save

Learn MongoDB
in 10 Mins
Lets Learn the Basics in 10 Minutes!

@code_station_
MongoDB is a rich open-source
document-oriented and one of the widely
recognised NoSQL database. It is written in
C++ programming language.

Database: A container for collections, where


each database has its own set of files on the file
system. A MongoDB server can host multiple
databases.
Collection: Similar to a table in a relational
database, it's a group of documents within a
single database. Collections don't enforce a
fixed schema, meaning documents within a
collection can have varying fields.
Document: A document is a set of key-value
pairs, serving as the fundamental unit of data
in MongoDB.

@code_station_
Install:
Download and install MongoDB from the
official website: ( mongodb.com )

Start MongoDB:
After installation, start the MongoDB server
using the command mongod in your terminal
or command prompt.
Access the MongoDB Shell:
Open another terminal or command prompt
window and enter mongo to access the
MongoDB shell.

@code_station_
Create a Database:
MongoDB stores data in databases. To
create a new database, use the use
command

Create a Collection:
In MongoDB, data is stored in collections.
Create a collection using the
db.createCollection() method

Insert Data:
You can insert data into a collection using
the insertOne() or insertMany() method.
For example:

@code_station_
Query Data:
Retrieve data using the find() method

Update Data:
Update data using the updateOne() or
updateMany() method:

Delete Data:
Remove data using the deleteOne() or
deleteMany() method:

@code_station_
Indexing:
Indexes can improve query performance.
Create an index using the createIndex()
method:

Exit the MongoDB Shell:


To exit the MongoDB shell, type exit.

Stop MongoDB Server:


In the terminal where you started the
MongoDB server, press Ctrl + C to stop it.

@code_station_
Logical Operators
MongoDB provides logical operators. The
picture below summarizes the different types
of logical operators.

@code_station_
Data types
String: Used for storing UTF-8 valid text data.
Integer: Stores numerical values (32-bit or 64-bit).
Boolean: Holds true or false values.
Double: Stores floating-point numbers.
Min/Max Keys: Used for comparing values
Arrays: Stores lists or multiple values within a single
key.
Timestamp: Handy for recording document times.
Object: Used for embedding documents.
Null: Stores a null value.
Symbol: Similar to a string but often reserved for.
Date: Stores current date/time in UNIX time format
or a custom date/time object.
Object ID: Stores a document's unique ID.
Binary Data: Used for storing binary data.
Code: Stores JavaScript code within a document.
Regular Expression: Stores regular expressions for
pattern matching.

@code_station_
Advantages of MongoDB over RDBMS

Schema less − MongoDB is a document


database in which one collection holds
different documents. Number of fields, content
and size of the document can differ from one
document to another.
Structure of a single object is clear.
No complex joins.
Deep query-ability. MongoDB supports
dynamic queries on documents using a
document-based query language that’s
nearly as powerful as SQL.
Conversion/mapping of application objects to
database objects not needed.
Uses internal memory for storing the
(windowed) working set, enabling faster
access of data.

@code_station_

You might also like