Data logical structure and storage structure

logical structure

The logical structure of MongoDB is a hierarchical structure. It mainly consists of three parts: document (document), collection (collection), and database (database). The logical structure is for developers. Developers of the N17 platform use the logical structure to develop applications using MongoDB.

The database is similar to the mysql database, the collection is similar to the mysql table, and the document is similar to a row of records in the table.

存储结构

MongoDB内部有预分配空间的机制,每个预分配的文件都用0进行填充,由于有了这个机制,MongoDB始终保持额外的空间和空余的数据文件,从而有效避免了由于数据暴增而带来的磁盘压力过大的问题。由于表中数据量的增加,数据文件每新分配一次,它的大小都会是上一个数据文件大小的2倍,每个数据文件最大2G。这样的机制有利于防止较小的数据库浪费过多磁盘空间的问题,同时又能保证较大的数据库有相应的预留空间使用。

Last updated