6

I just have a question about how to choose between using a noSQL database or sql database when creating a ReactJS or React Native app? For instance why would you choose to use Firestore over PostgreSQL or vis versa?

Specifically for me, if I were making a react native (mobile) game where players each have their own bag with an inventory where all of this data is stored in a database which method should I use, Firestore or PostgreSQL and why? Additionally, I would want other players to look at each other's bags and rate them.

1
  • My 2 cents is... start with Firestore and get a feel of it. Only when you absolutely cannot get Firestore to work for you, switch back to Postgres. Since this is a mobile game, Firestore is meant for such use cases. Commented Jan 15, 2019 at 2:30

1 Answer 1

8

I had the same question, and wanted a definitive answer (I don't provide that here 😅), especially since some people on hacker news were preferring using generic services which don't lock you into a Cloud provider.

Benefits of PostgresQL

  • More people are familiar with PostgresQL than Firestore. It is the standard. Data scientists, infrastructure and normal developers will know how it works. Firestore is a niche offering by Google, and only people in the Firebase ecosystem will know what that is. It may be designed to be simple, but don't underestimate it: a few years ago, apps leaked all their sensitive data or allowed anyone to empty out their entire database (That was firebase 😁). Also, people were inefficiently making queries in Firebase and costing their company thousands of dollars with no real benefit. If using Firestore, you need to make sure you deeply understand its paradigm: e.g. how the queries work, and also the security rules, and most people won't.
  • If one day a new serverless database product is created or open sourced, it might be hard to migrate from Firestore to it, than it would be to migrate from Postgres to the same. You're locked into the Firebase ecosystem.
  • You don't have to install the firebase SDK into your app, who knows what that library does without watching the network traffic...

Benefits of Firestore

  • You only pay for reads, writes, deletes and the actual data size stored. Postgres will need to be hosted somewhere, so that will cost you money immediately, even if someone doesn't use your app. Sure, AWS some serverless database offering called Aurora Serverless, but you pay per hour, so even if nobody uses your app, you're paying!
    • Pricing summary: If nobody uses your app in one month, Firestore is free. AWS Aurora is $60 for a basic machine db.t3.medium. Firestore also has a free tier.
    • In both cases, you can say you pay what you "use", but in Firestore usage is actual benefit to the user, where as usage in AWS would be the machines youre using.
  • Integrated with the rest of Firebase
  • Firebase makes great videos and integrates with other Google stuff well (Android, Flutter), for example, this fun one and this serious one.

You can compare SQL vs NoSQL somewhere else, but I think the differences (data duplication vs normalised data, performance) are not a big deal compared to the other issues here I mentioned (productivity and cost), especially when you're making a basic apps. More complex applications will want a thorough evaluation of different databases, not just differentiating between NoSQL/ SQL.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.