What is considered as a document in mongoDB?

2019-06-02 03:59发布

问题:

I have been learning mongoDb for past two days,I've been confusing with documents and their limits,and how to overcome the limits.What is a differnce between documents and collection.

回答1:

To roughly compare it with a traditional RDBMS:

RDBMS        |            MongoDB
_________________________________________
Database     |            Database
Table        |            Collection
Tuple/Row    |            Document
column       |            Field
Primary Key  |            Primary Key (Default key _id provided by mongodb itself)

Processes:

Database Server(Daemon process) and Client
Mysqld/Oracle        |            mongod
mysql/sqlplus        |            mongo

mongos is the mongo server used during load balancing in a sharding and/or replica set scenario.

Hence in mongodb, database consists of collections of documents and each document contains any number of key value pairs.

Different documents in the same collection can have different number and type of keys. You can say its schema-less; at the most basic part: everything is based on retrieving values from hash values or hash indices of keys.

Within a document, keys can have values ranging from normal primitive datatypes(string, int, binary data etc) to documents and arrays.

As for the document limit size, 16 MB is sufficient as mongodb stores your data in Binary JSON (BSON) compressed format. Also embedded documents are not stored separately wrt the parent document and are counted within the 16 MB limit. Here are few more links on document limit:

latest change of mongodb document limit
doc limit
link
deciding factor
more info



标签: mongodb nosql