What does MongoDB document storage mean?

mongodb is the way key-value is stored, and like redis, their value supports multiple data types.
how to understand the document storage of MongoDB, does it mean that it can store word documents or Excel or pictures directly? Unlike mysql, it is the path where they are stored.
take a look at the brief introduction of MongoDB and redis, and feel that what MongoDB can do, redis can also do. Why choose MongoDB in some scenarios. For example, you need to display data in real time, and both can be done.

is it because I don"t understand them thoroughly enough?

Mar.17,2022

some superficial understanding

documents are generally stored in a format similar to json, and the stored content is document-based. In this way, there is an opportunity to index some fields and implement some of the functions of a relational database.

MongoDB is between a relational database and a non-relational database. Each record is a document (corresponding to the row), of the relational database, a batch of documents form a document group (that is, a collection, and the corresponding table), can index some fields of the document. You can support rich query languages like relational databases.

Redis non-relational database, hash supports simple relationships, key-value reads fast, but does not support complex relationships, does not support field indexing, and is not suitable for query and search.


Don't be so complicated. Take storing an article as an example, the article has fields:

  1. title
  2. content
  3. Picture
  4. time

when using relational data storage, you may create an article table, and then create corresponding fields to store the corresponding data.
and MongoDB simply stores the field and its corresponding content as a json (json below).

{
    "title":"",
    "content":"",
    "img":"",
    "createTime":""
}

based on the two ways, you will see that if it is a relational database, you may have to consider a lot of things if you want to add or delete a field. But for MongoDB, it is OK to add the corresponding fields and contents directly to the json, and it is very convenient to add and delete fields.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e80644-45558.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e80644-45558.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?