Understanding Documents
A document is a representation of a single entity of data in a MongoDB database. A collection is made up of one or more related objects. There is a major difference between MongoDB and SQL in that MongoDB documents are very different from SQL rows. Row data is very flat, meaning there is one column for each value in the row. However, in MongoDB, documents can contain embedded subdocuments, thus providing a much closer inherent data model to your applications.
In fact, the records in a MongoDB database that represent documents are stored as BSON, which is a lightweight binary form of JSON. In addition, MongoDB field/value pairs correspond to JavaScript property/value pairs. These field/value pairs define the values that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access