I can't think in NoSQL (and neither can you)

If you're like me, a programmer taught how to think in terms of relational databases, you just can't design a NoSQL. Wait. No one can design a proper NoSQL database for relational data because it's a data store built on tradeoffs. 

I have very relational data that I am being forced to feed into Firebase just because of how convenient Firebase is to set up. Here's a simplified problem statement:

  • There are Users, each of whom has an email, name, and gender.
  • These users can be friends, and have to consent to their friendship - sent, pending, and accepted.
  • Create a NoSQL json table such that there is no duplication of data, and each user is able to query a list of their friends including invites with all the user details.

Your tradeoff is effectively choosing between optimizing one of either read or write. No matter how you structure your code, you'll end up with either:
  • Optimize reads, data duplication (View Code)
    Each user contains all of their friend's data within their nodes.
  • Optimize writes, multiple read calls (View Code)
    Every time a user wants a list of all their friends, they have to query each user.

I'm trying very hard not to say this but: anyone who chooses a NoSQL database claiming it allows rapid prototyping and gives you agility - I don't want to work with you. Most real-world application data is relational.


Popular posts from this blog

[Breaking News] AI takes over universe to calculate Pi

Firebase Auth | The Debug vs Release Signature Problem

Finding My Parter