Overview of MongoDB

MongoDB is a cross-platform database, operating on the concepts of Collection and Document, it provides high performance, high availability and easy scalability.

MongoDB is a cross-platform database, operating on the concepts of Collection and Document, it provides high performance, high availability and easy scalability.

Concept Database

Database is a physical container for Collection. Each Database gets its own set of files on the file system. Each MongoDB Server can have multiple databases.

Concept Collection

Collection is a group of Documents in MongoDB. It is equivalent to a table in RDBMS. Therefore, a Collection exists within a single database. Collections do not bind Relationship as other database management systems, so the access is very fast, so each collection can contain many different types unlike the table in the mysql administration system that is the fixed fields. determined. Documents inside a Collection can have many different fields. In particular, all Documents in a Collection are similar or with the same purpose.

Concept of Document

A Document in MongoDB, has a structure similar to the JSON data type, is a set of key-value pairs. Documents with schema dynamics, meaning Document in the same Collection need not have the same set of fields or structures, and common fields in a Collection's Document can hold different data types.

Below đưa ra table shows relationship của RDBMS terminology with MongoDB

RDBMSMongoDBDatabase Database Table Collection Tuple / Row Document column Field Table Join Embedded Documents Primary Key Primary Key (Default value is _id provided by MongoDB itself) Database Server and ClientMysqld / Oracle mongod mysql / sqlplus mongo

Simple Document structure

The following example illustrates the Document structure of a Blog site with a key-value pair distinguished by commas.

 { _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 } ] } 

Here, _id is a 12-byte hexadecimal number to ensure the uniqueness of each Document. You can provide _id while inserting into the Document. If you do not provide it, MongoDB will provide a unique id for each Document. In these 12 bytes, the first 4 bytes are for the current Timestamp, the next 3 bytes for the device ID, the next 2 bytes are the process id of MongoDB Server and the remaining 3 bytes are the possible values.

According to Tutorialspoint

Last lesson: Different platforms in Git

Next article: Advantage of MongoDB

4 ★ | 2 Vote