What is a Document and Collection in MongoDB? [2]

What is a Document and Collection in MongoDB? [2]

Document - is a way to organize and store data as a set of field-value or key-value pairs.

Document contains:

Field/Key - is a unique identifier for a document.
Value - data related to a given identifier.
{
  <field>: <value>,
  <key>: <value>,
  name: 'Ram',
  age: 20
}
Document example

👉ALL MONGODB SERIES


Collection - an organized store of documents in MongoDB, usually with common fields between documents. There can be many documents per collection and many collections per database .

{
  name: 'Ram',
  age: 20
},
{
  name: 'Shyam',
  age: 21
},
{
  name: 'John',
  age: 22,
  <field>: <value>
}
...
Collection of documents, having common fields: name, age

What is MongoDB Atlas?

What is MongoDB Atlas?
Atlas is Database as a Service. Atlas helps us Visualize, Analyze, Export and build applications with our data. We will use Atlas to setup MongoDB Database in the Cloud.

Quiz:

1) In MongoDB how does a document relate to a collection?
Collection consist of one or many documents.

2) In a MongoDB Document what is the role of fields and values?
* A field is a unique identifier for a specific document.
* Each field has a value associated with it.

👉ALL MONGODB SERIES


Reference: university.mongodb.com | MongoDB, Inc.