Mongodb
Mongodb
If you are unfamiliar with JSON, check out our JSON tutorial.
A record in MongoDB is a document, which is a data structure composed of key value pairs similar to the
structure of JSON objects.
A MongoDB Document
Records in a MongoDB database are called documents, and the field values may include numbers,
strings, booleans, arrays, or even nested documents.
Eg:
{
title: "Post Title 1",
body: "Body of post.",
category: "News",
likes: 1,
tags: ["news", "events"],
date: Date()
}
****************************************************************************************************************
SQL vs Document Databases
SQL databases are considered relational databases. They store related data in separate tables.
When data is needed, it is queried from multiple tables to join the data back together.
This does not mean that relational data cannot be stored in document databases.
It means that relational data is stored differently. A better way to refer to it is as a non-tabular database.
Instead of having multiple tables you can simply keep all of your related data together. This makes
reading your data very fast.
You can still have multiple groups of data too. In MongoDB, instead of tables these are called collections.
*****************************************************************************************************************
MongoDB can be installed locally, which will allow you to host your own MongoDB server on your
hardware.
This requires you to manage your server, upgrades, and any other maintenance.
You can download and use the MongoDB open source Community Server on your hardware for free.
However, for this course we are going to use MongoDB Atlas, a cloud database platform.
To be able to experiment with the code examples, you will need access to a MongoDB database.
Adhoc queries with mongosh, Compass, VS Code, or a MongoDB driver for the programming language
you use.
Full-text search.