Mongo DB
Mongo DB
GETTING STARTED
UPDATE ON THE PLAN AND PROGRESS
UNIT 1 : MONGODB
MONGODB – OVERVIEW
Database Collection
Database is a physical container for Collection is a group of MongoDB
collections. Each database gets its own documents. It is the equivalent of an
set of files on the file system. A single RDBMS table. A collection exists within a
MongoDB server typically has multiple single database. Collections do not
databases. enforce a schema. Documents within a
collection can have different fields.
Typically, all documents in a collection
are of similar or related purpose.
MONGODB – OVERVIEW
RDBMS MongoDB
Database Database
Table Collection
Document
A document is a set of key-value pairs.
Tuple/Row Document Documents have dynamic schema. Dynamic
column Field
schema means that documents in the same
collection do not need to have the same set of
Embedded fields or structure, and common fields in a
Table Join
Documents collection's documents may hold different types
Primary Key of data.
(Default key
Primary Key _id provided by
MongoDB
itself)
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.
• Tuning.
• Ease of scale-out − MongoDB is easy to scale.
• Conversion/mapping of application objects to database objects not needed.
• Uses internal memory for storing the (windowed) working set, enabling faster access of data.
Document Oriented Storage − Data is stored in
the form of JSON style documents.
Rich queries
for Ubuntu 20
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
Basic syntax of use DATABASE statement is as follows −
use DATABASE_NAME
CREATE DATABASE
>db
mydb
If you want to check your databases list, use the command show dbs.
>show dbs
local 0.78125GB
test 0.23012GB
THE DROPDATABASE() METHOD
>show dbs
local 0.78125GB
mydb 0.23012GB
test 0.23012GB
>use mydb
switched to db mydb
>db.dropDatabase()
>{ "dropped" : "mydb", "ok" : 1 } >