MongoDB is a cross-platform, file oriented database that provides, high performance, high availability, and clean scalability. MongoDB works on idea of collection and record.
Database
Database is a physical box for collections. Each database gets its very own set of documents at the record device. A single MongoDB server normally has more than one databases.
Collection
Collection is a collection of MongoDB files. It is the equal of an RDBMS desk. A collection exists within a unmarried database. Collections do no longer implement a schema. Documents within a set can have different fields. Typically, all documents in a collection are of similar or associated purpose.
Document
A file is a set of key-value pairs. Documents have dynamic schema. Dynamic schema means that documents in the equal collection do now not want to have the equal set of fields or shape, and commonplace fields in a set's documents might also keep distinctive varieties of information.
The following table shows the relationship of RDBMS terminology with MongoDB.
RDBMS | MongoDB |
---|---|
Database | Database |
Table | Collection |
Tuple/Row | Document |
column | Field |
Table Join | Embedded Documents |
Primary Key | Primary Key (Default key _id provided by MongoDB itself) |
Database Server and Client | |
---|---|
mysqld/Oracle | mongod |
mysql/sqlplus | mongo |
Sample Document
Following instance indicates the report shape of a blog site, which is actually a comma separated key price pair.
{
_id: ObjectId(7df78ad8902c)
title: 'MongoDB Overview',
description: 'MongoDB is no sql database',
by: 'tutorials point',
url: 'http://www.tutorialspoint.com',
tags: ['mongodb', 'database', 'NoSQL'],
likes: 100,
comments: [
{
user:'user1',
message: 'My first comment',
dateCreated: new Date(2011,1,20,2,15),
like: 0
},
{
user:'user2',
message: 'My second comments',
dateCreated: new Date(2011,1,25,7,45),
like: 5
}
]
}
_id is a 12 bytes hexadecimal range which assures the distinctiveness of each document. You can offer _id even as placing the document. If you don’t offer then MongoDB gives a completely unique id for each file. These 12 bytes first four bytes for the modern-day timestamp, subsequent three bytes for system id, next 2 bytes for technique identity of MongoDB server and last three bytes are simple incremental VALUE.