Mongo DB

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

MongoDB getting started

document is the basic unit of data for


MongoDB and is roughly equivalent to a row
in relational DBMS.
Similarly, a collection can be thought of as
a table with dynamic schemas.
Every document has a special key, _id,
that is unique within collection.

Documents
document: an ordered set of keys with
associated values.
In javascript, for example, documents are
represented as an objects:
{greeting : hi, good morning}
A simple document consist of a single
key, greeting, with a value hi, good
morning
A complex document consist of multiple
key/value pairs:
{greeting : hi, good morning, id:2}

Conti..
The

keys in a document are strings.


MongoDB is case-sensitive and typesensitive.
Eg: {foo: 3}
{Foo: 3} are different.
MongoDB cannot contain duplicate
keys.
Eg: {foo: 3 , foo: 2}
Key/value pairs in documents are
ordered.

Collections
A

collection is a group of
documents.
If a document is the MongoDB
analog of a row in relational
database, then a collection is the
analog to a table.

Relationship of RDBMS terminology with MongoDB

_id:
_id

is a 12 bytes hexadecimal number


which assures the uniqueness of
every document. You can provide _id
while inserting the document. If you
didn't provide then MongoDB provide a
unique id for every document.
These 12 bytes first 4 bytes for the
current timestamp, next 3 bytes for
machine id, next 2 bytes for process id of
mongodb server and remaining 3 bytes
are simple incremental value.

MongoDB Advantages
Advantages

of MongoDB over RDBMS


Schema less : MongoDB is document database in which
one collection holds different different documents. Number
of fields, content and size of the document can be 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

Db.help()
To get list of commands type
db.help() in mongodb client.
This will give you list of
commands as follows:

Ref:
http://navinwbackup.blogspot.in/201
4/07/pl01-osd-practicals.html
http://www.imfrosty.com/2014/10/pl
1-b2.html

You might also like