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.

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

May be interested

  • Shard in MongoDBShard in MongoDB
    sharding is a process of storing data records across multiple devices and it is a method of mongodb to meet the requirement for increasing data. when the size of the data increases, a single device cannot be enough to store data.
  • Learn about Java Driver in MongoDBLearn about Java Driver in MongoDB
    in the following article, we will introduce you some basic features of mongodv java driver as well as how to deploy and apply in practice.
  • Install MongoDBInstall MongoDB
    instructions for installing mongodb on windows.
  • Map Reduce in MongoDBMap Reduce in MongoDB
    in mongodb documentation, map-reduce is a data processing system that condenses a large amount of data into useful overall results. mongodb uses mapreduce command for map-reduce operation. in general, map reduce is used to handle large data sets.
  • Aggregation in MongoDBAggregation in MongoDB
    aggregation can be understood as aggregation. the aggregation operation handles data records and returns calculated results. the operations group the values ​​from multiple documents together, and can perform multiple operations on the grouped data to return a single result. in sql, count (*) and group by are equivalent to aggregation in mongodb.
  • Data modeling in MongoDBData modeling in MongoDB
    data in mongodb has a flexible schema. documents in the same collection need not have the same set of fields or structures, and common fields in collection documents can keep different data types.
  • How to use Aggregation Pipeline in MongoDBHow to use Aggregation Pipeline in MongoDB
    if you are using mongodb's mapreduce, it is best to switch to aggregation pipeline for more efficient computation.
  • GridFS in MongoDBGridFS in MongoDB
    gridfs is the mongodb specification for storing and collecting large files such as images, audio, video files, etc. it is a type of file system to store files but its data is stored inside mongodb collections. .
  • Query analysis in MongoDBQuery analysis in MongoDB
    analyzing queries is a very important aspect to assess the effectiveness of database and the effectiveness of the designed index. we will explore the two most frequently used queries, $ explain and $ hint.
  • Projection in MongoDBProjection in MongoDB
    in mongodb, projection's meaning is to select only the necessary data instead of selecting the entire data of a document. if a document has 5 fields and you only need 3 fields, you should only select 3 fields from that document.