25

Which is better, MongoDB or Firebase?

 4 years ago
source link: https://www.tuicool.com/articles/NniQ7vQ
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Adebayo Opesanya , Full Stack (MEAN) & Cloud App Developer. Technical Writer.

Updated 5w ago

Updated 5w ago · Author has 260 answers and 429.4k answer views

Thanks for the A2A. When you say Firebase, I assume you are referring to the Realtime Database product.

I’ll give two answers; a short one and a long one.

Short Answer: None of them is better.

I say this because they are quite different in many ways, and a better question to ask is which of them suits your unique use case. Whichever one fits better, gets the prize.

Long Answer

Firebase is very useful if you fit one of the following scenarios:

  1. You are a startup and want to spin off an MVP as soon as possible. You want to do this without the headache of designing and maintaining a full backend architecture.
  2. You fit number 1 and your application requires that you give realtime updates on several devices based on data changes.
  3. Firebase also offers realtime synchronization of data. Your clients can make updates even when they are offline, and the data synchronizes automatically when they are back online.

Firebase is great, but there are some drawbacks I have seen with using Firebase:

  1. Building an API for your application is near impossible; at best inefficient. It is better to just build your own API using a standard backend architecture.
  2. Handling relations can be a pain in the neck. It is already bad enough that handling relations in a NoSQL environment can be a tedious task. Thinking of how to handle relations in Firebase??? Let me give a quick example: Imagine a school system where every student belongs to a class and then in each class there are various students. It means that every student has to watch class IDs, and then populate on your own classes and your class has to watch student IDs and populate users. Thinking about it is even painful enough. It’ll be worse when you start adding subjects, and then imagine some subjects are optional…Just complex!
  3. Firebase Realtime Database can become really costly at some point.
  4. Firebase is cloud hosted, so you might no be able to work on your app in your local environment during development. If you live in a place like Nigeria where I live, you’ll understand that connectivity isn’t a light matter at all.
  5. MongoDB provides you with a rich schema to query your data, providing more flexibiltly. Firebase…well…
  6. Firebase downloads all subtrees on load, and that can be a huge performance drawback.

I’m not sure i’ve covered all the necessary checkpoints, but these ones come foremost to my mind. Please consider carefully these things before you make a final decision for your application. A mistake here can be quite costly.

You can send a DM on Twitter if you have further questions.

30.7k views · · · Answer requested by Abdulaziz Alkharji


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK