Mongodb entry 2 documentation, set, database

Source: Internet
Author: User
Mongodb getting started-2 Documents, collections, and databases no matter what databases we learn, we should learn the basic concepts. In mongodb, the basic concepts are documents, collections, and databases. Next we will introduce them one by one. Document: The document is the core concept of mongodb and the core unit. We can compare the document to the number of rows in a relational database.

Mongodb getting started-2 Documents, collections, and databases no matter what databases we learn, we should learn the basic concepts. In mongodb, the basic concepts are documents, collections, and databases. Next we will introduce them one by one. Document: The document is the core concept of mongodb and the core unit. We can compare the document to the number of rows in a relational database.

Mongodb entry 2 documentation, set, database

No matter what database we learn, we should learn the basic concepts in it. The basic concepts in mongodb are documents, sets, and databases. Next we will introduce them one by one.

Documentation:

A document is the core concept of mongodb and its core unit. We can compare it to every row of data in a relational database. Multiple keys and their associated values are put together in an orderly manner. In mongodb, a type of json bson is used to store data. Bson data can be understood as adding some data types not in json on the basis of json. If we use json, we have half of bson's knowledge. I will introduce the newly added data types later. Example:

[Html]

{"Name": "mengxiangyue", "sex": "nan "}

There are some restrictions on the document: ordered, case-sensitive, so the following two documents are different from the above

[Html]

{"Sex": "nan", "name": "mengxiangyue "}

{"Name": "mengxiangyue", "sex": "nan "}

Set:

A set is a combination of documents. If a document is analogous to a row in a database, the set can be analogous to a database table.

In mongodb, the set is unformatted. That is to say, the structure of the stored documents in the collection can be different. For example, the following two documents can be saved to one collection at the same time:

[Html]

{"Name": "mengxiangyue "}

{"Name": "mengxiangyue", "sex": "nan "}

This is different from a relational database. All rows in the relational data have the same fields. It cannot be the same as in mongodb. Although the collection of mongodb has no mode, the official mongodb recommends that all documents have the same structure, which makes it easier to process.

Database:

The concept of databases in mongodb is basically the same as that in relational databases. Databases in mongodb are a combination of multiple sets. You can also create multiple databases in a mongodb instance. These databases are also independent of each other and can also perform user verification independently.

When naming a database, the admin, local, and config are retained. These databases are reserved for mongodb.

The admin database is a root database. if you add a user to the database, the user inherits the permissions of all databases and will be used in future.

Local database. This database will not be copied and will only store the databases that can be accessed by the local server. It will be reduced to the next part.

The config database is used to save information about shards.

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.