Sunday, September 15, 2019

MongoDB - Database and Collection

Click the link: "MongoDB - Database and Collection"

In this MongoDB tutorial we will learn about databases, collections and documents.

What is a document?

A document is a key value pair. It is a JSON (JavaScript Object Notation).
Following example represents a student document.
{
  "student_id": "s0001",
  "first_name": "Yusuf",
  "last_name": "Shakeel"
}
student_idfirst_name and last_name are referred as the fields or keys of the document and s0001Yusuf and Shakeel are the respective values of the given fields.
If you are familiar with RDBMS (eg. MySQL) then a MongoDB document is like a row in a RDBMS table.

What is a collection?

A collection is a set of documents.
A single collection can have zero or more number of documents.
Think of MongoDB collections as tables in RDBMS.

No comments:

Post a Comment