Letâs start from the very beginningâŚ.
What is a database?
Itâs just a base/place for data, itâs as simple as that.
However, the bigger question is âwhy canât you use something like an excel sheet to store data?â
The answer is yes you can but it depends more on what youâre trying to do
An excel sheet is perfect if youâre the only person using/updating the data, now when you scale up to more than say 3 people (in different locations), try to have the excel file store the most up-to-date data as possible, youâll see exactly why the excel file is a terrible idea.
What are the different types of databases?
Traditionally people used something called Structured Query Language (SQL, đ: sequel), It basically created commands to do what you would to in an excel table.
example: if you wanted to insert a row into the table, instead of opening the table and manually entering values to the table, you would now do
INSERT INTO table(column1, column2,...)
VALUES (value1, value2,...);
TL;DR it kinda made excel programmable.
Present-day humanity, we have 2 main types of databases
-
SQL: uses tables to store data
-
NoSQL: uses key-value pairs to store data
Reading that you may be thinking why did humans bother to come up with NoSQL, it seems easier to store data in tables rather than in key-value pairs.
Well, on that you arenât wrong, it is easier to store data in an SQL database disregarding the fact that you have to learn an entire language for it.
The main problem occurs when youâre looking to scale beyond 1000 people(ig), especially when the storage on the server(or pc in this case) is exhausted.
In NoSQL, you can do this very easily by simply just splitting data into n parts and merging it in different systems later,
unlike in SQL where merging is complicated, you have to create a pre-defined schema(blueprint), share the blueprint and then split data, not to mention ensure your index for each row is unique especially for the new data that you add.
The Major Players in the NoSQL Battleground
So for the average developer, while choosing a NoSQL database, typically has 2 choices:
-
Firestore
-
MongoDB
-
⌠( There is always a 3rd option, you just may not know what it is đ)
Letâs Talk About MongoDB
This is a pretty well-established database and itâs currently the database of choice for most people (excluding me), but that is obviously because they have their needs.
MongoDB came out in 2009, and it was basically the only noSQL database easily available for public use at that time.
That led to the butterfly effect that made it so well established, but that doesnât explain why no other database has overthrown it yet.
Now, when mongoDB came it was an offline database (it wasnât on the cloud), but as the times changed it adapted to the changes, actually the community (fans that use+love+live it) ensured it adapted to changes.
The community came up with mLabs, a cloud-based mongoDB database.
mLabs is what turned out to become the present dayâs mongoDB atlas
Letâs Talk About Firestore
Firestore is the flagship database of googleâs BaaS [backend as a service] (pre-coded/setup server)
QuickNote: Firebase runs on top of GCP googleâs IaaS [infrastructure as a service] ( the server hardware, uncoded/setup)
Most people think firebase is the database (due to a common ending âbaseâ), but NO, firebase is a backend and offers a lot of additional services like hosting, authentication and analytics.
That is firestoreâs key selling point right now.
Easy to use, free ( as long as you are in the free-tier ), with a lot of additional features
When To Use MongoDB over Firestore
Firestore comes under firebase, where you have 0 control over what you can configure/host there.
**Use Case: **When you need a server, where you plan to have custom-built APIs like
-
ML model
-
APIs that serve sensor data [eg: open weather map, etc.]
In this case, you already have and are paying for computation resources, so itâs most economical to stick to 1 service.
You could:
-
host a local mongoDB instance in the server.
-
connected to the cloud-hosted mongoDB Altas cluster.
When To Use Firestore over MongoDB
When the only central(server) resource that youâre using is a database, itâs more beneficial to use than mongoDB.
Use Cases: an app or a SPA(client-rendered web app)
Lemme place more emphasis on using firebase if the only additional resources you need is a database.
untill next time !ď¸ â
or you could spot me in the wild đ¤ i mean instagram, twitter, linkedin and maybe even youtube where i excalidraw those diagrams