MongoDB (vii) MONGODB data structure

Source: Internet
Author: User


First, insert a Bjson data into the database

The first is to define the document, then log in with the admin username password, enter the test database, insert this document into the test database ("table name and records in table")




Insert results, view Mongovue as shown



We can see that the system comes with three databases, local,admin,test, when adding a record, will automatically generate _id automatic identification.

We'll add the picture again, which can be added using Mongovue, as shown in.




Collections: Called a collection in MongoDB, is a collection of documents. No mode, you can store a variety of documents. Like a table in MySQL.

In a relational database, each table in a relational database is a mapping of a relational model, and each table field is a collection of attributes and primary foreign keys for the corresponding entity, and each field needs to be defined in advance.

Document: The User collection ("table") here has a document (document can be understood as a record in MySQL). A document is a basic unit for MongoDB to save data. The data is stored in the Bson format, which is the document we started to add, the key value pair type.

The document can be saved to a data type that is: null, Boolean, String, Object, 32-bit integer, 64-bit integer, 64-bit floating-point number, date, regular expression, JS code, binary data, array, inline document, maximum, minimum, undefined type.


Gridfs: Because the size of the Bson object is limited, it is not suitable for storing large files, Gridfs file system provides a storage scheme for large files, and the FS under Gridfs is saving large files such as pictures and video screens.

Whether it is a Bson object or a large file stored in the grifs, we find that when a document is added, it is automatically added _id, the difference is that the image is added automatically after the addition of _id,chunksize,md5,legnth,aliases, etc. These properties are after we upload the image, after MongoDB analysis automatically added, the system automatically saved.




MongoDB (vii) MONGODB data structure

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.