MongoDB Study Notes (1)-learn about MongoDB

Source: Internet
Author: User
Tags relational database table
MongoDB is an open-source, non-schema document-based database and a popular nosql database (non-relational database)

MongoDB's data structure is very loose. It is similar to the JSON bjson format and supports data indexing. It is a set-oriented, free-of-charge document-type database.

 

1. Set-oriented

It means that the data is stored in a dataset by group and called a collection.

2. Free mode

This means that we do not need to know any structure definition of the files stored in the MongoDB database. I mentioned this many times "NO mode" or "Free mode". What does it mean? For example, the following two records can exist in the same set:

{"Welcome": "Beijing"} {"Age": 25}

 

Features:

Oriented to centralized storage, it is easy to store object-type data

The free mode supports dynamic query and supports full indexing, including internal objects that support querying and use efficient binary data storage for replication and fault recovery, including automatic fragment processing for large objects (such as videos, bson (JSON extension)

 

Architecture:

A series of physical files (data files, log files, etc.) in MongoDB)

The document of MongoDB is equivalent to a row of records in a relational database.

Multiple documents form a collection, which is equivalent to a relational database table.

Multiple collections are logically organized together, that is, databases)

Data storage structure:

In MongoDB, each database contains a. Ns file and some data files, and these data files will become more and more as the data volume increases. So if there is a database named Foo in the system, the files that constitute the foo database will be composed of foo. NS, foo.0, foo.1, foo.2, and so on.

MongoDB has a pre-allocated space mechanism. Each pre-allocated file is filled with 0. Because of this mechanism, MongoDB always maintains extra space and spare data files, this effectively avoids the disk pressure caused by the Data surge.

As the amount of data in the table increases, the size of each data file is twice the size of the previous data file, and the maximum size of each data file is 2 GB. This mechanism helps prevent small databases from wasting too much disk space. At the same time, it can ensure that large databases have corresponding reserved space.

Each table in the database corresponds to a namespace, and each index also has a corresponding namespace. The metadata of these namespaces is concentrated in the *. Ns file.

Note the namespace: $ freelist, which is used to record the disk areas (Deleted collection or indexes) that are no longer in use ). Whenever a namespace needs to be allocated to a new disk area, you will first check whether $ freelist has a suitable Disk Area for use, so as to reclaim free disk space.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.