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

MongoDB Basics

MongoDB is a document-oriented NoSQL database that uses collections and documents instead of tables and rows. Documents consist of key-value pairs and can have different structures. Collections contain documents and are equivalent to tables. MongoDB allows flexible, hierarchical data structures and dynamic schemas. Documents are analogous to objects and have fields instead of columns. CRUD operations allow creating databases and collections.

Uploaded by

Ritu Raj
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)
81 views

MongoDB Basics

MongoDB is a document-oriented NoSQL database that uses collections and documents instead of tables and rows. Documents consist of key-value pairs and can have different structures. Collections contain documents and are equivalent to tables. MongoDB allows flexible, hierarchical data structures and dynamic schemas. Documents are analogous to objects and have fields instead of columns. CRUD operations allow creating databases and collections.

Uploaded by

Ritu Raj
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/ 10

MongoDB Basics

Adapted from
https://www.guru99.com/mongodb-tutorials.html
Intro,
Architecture,
Features
What is MongoDB

MongoDB is a document-oriented NoSQL database


Instead of using tables and rows as in the traditional relational
databases, MongoDB makes use of collections and documents.
Documents consist of key-value pairs which are the basic unit of
data in MongoDB.
Collections contain sets of documents and and is the equivalent of
RDBMS tables.
Features

Database contains collections which in turn contains documents.


Document can be different with a varying number of fields.
● Size and content of each document can be different from each other.
● Similar to classes and objects in their respective programming languages.
● Have a clear structure with key-value pairs.
● The rows (or documents as called in MongoDB) doesn’t need to have a schema
defined beforehand, fields can be created on the fly.
● Allows hierarchical relationships, arrays, and other more complex structures
Document Structure

1. id – required in every MongoDB document.


The _id field represents a unique value in the
MongoDB document like the document’s
primary key. Automatically created
2. Cursor – This is a pointer to the result set of a
query. Clients can iterate through a cursor to
retrieve results.
3. JSON – This is known as JavaScript Object
Notation. This is a human-readable, plain text
format for expressing structured data. JSON is
currently supported in many programming
languages.
Document(JSON) structure
● [

● {

● "Name": "Tom",
● The document has simple structure and very ● "Age": 30,
easy to understand the content ● "Role": "Student",

● JSON is smaller, faster and lightweight ● "University": "CU",

compared to XML. }

{
● For data delivery between servers and browsers,
● "Name": “Sam",
JSON is a better choice
● "Age": 32,
● Easy in parsing, processing, validating in all ● "Role": "Student",
languages ● "University": “OU",

● JSON can be mapped more easily into object }

oriented system. ]
RDBMS vs MongoDB
RDBMS MongoDB Difference

Table Collection In RDBMS, the table contains the columns and rows which are used to store the data whereas, in MongoDB,
this same structure is known as a collection. The collection contains documents which in turn contains Fields,
which in turn are key-value pairs.

Row Document In RDBMS, the row represents a single, implicitly structured data item in a table. In MongoDB, the data is
stored in documents.

Column Field In RDBMS, the column denotes a set of data values. These in MongoDB are known as Fields.

Joins Embedded In RDBMS, data is spread across various tables and in order to show a complete view of all
documents data, a join is formed across tables to get the data. In MongoDB, the data is normally
stored in a single collection, but separated by using Embedded documents. So there is no
concept of joins in MongoDB.
CRUD Operations
Create Database, Collections
Python MongoDB

You might also like