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

Mongo DB

- A document is the basic unit of data in MongoDB, equivalent to a row in a relational database. A collection contains related documents and is equivalent to a table. - Every document requires a unique "_id" key. Documents are ordered sets of key-value pairs that can contain different fields. - Collections contain groups of documents and are the equivalent of tables. Keys in documents are case-sensitive and type-sensitive. Duplicate keys are not allowed within a document. - The "_id" key provides a unique identifier for each document. If not provided, MongoDB automatically generates a unique "_id".

Uploaded by

Ruta Kulkarni
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
175 views

Mongo DB

- A document is the basic unit of data in MongoDB, equivalent to a row in a relational database. A collection contains related documents and is equivalent to a table. - Every document requires a unique "_id" key. Documents are ordered sets of key-value pairs that can contain different fields. - Collections contain groups of documents and are the equivalent of tables. Keys in documents are case-sensitive and type-sensitive. Duplicate keys are not allowed within a document. - The "_id" key provides a unique identifier for each document. If not provided, MongoDB automatically generates a unique "_id".

Uploaded by

Ruta Kulkarni
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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