DEV Community 👩‍💻👨‍💻

John Paul Ada
John Paul Ada

Posted on

Need Help: Relational vs. Document-based Databases -- What are the pros and cons?

Hey guys! I need help with the pros and cons of relational vs document-based databases. We're building a progressive web app. I want to hear your thoughts on the comments below!

Top comments (8)

Collapse
dmfay profile image
Dian Fay

There's really only one question to ask: is your data model relational?

If your model includes discrete entities connected in a dependency graph, use a relational DBMS or you will more than likely regret it. If you've got strictly hierarchical or arborescent data with few to no interconnections between entities, then it's time to look into document dbs. I've said it before and I'll say it again: if you can't articulate why you need something other than an RDBMS, you need an RDBMS.

Collapse
johnpaulada profile image
John Paul Ada Author

I agree. Is there a way to build a realtime system over a relational database? The go to platform is Firebase but an RDBMS makes more sense to me

Collapse
dmfay profile image
Dian Fay

What does "realtime" mean in this context? Properly designed and indexed relational databases are plenty fast until you get to extreme scales.

Collapse
dmerand profile image
Donald Merand

Look into Phoenix, it's got good RDBMS support, and excellent soft real-time performance because it's backed by the BEAM VM.

Thread Thread
johnpaulada profile image
John Paul Ada Author

I totally agree with this. LOL. Still trying to wrestle with Ecto though.

Collapse
rhymes profile image
rhymes
Collapse
kspeakman profile image
Kasey Speakman

From your other comment, you mention realtime systems. This is a different problem from a database and has more to do with communications. Firebase just packages things together for you. For example, Postgres (a relational DB) has LISTEN/NOTIFY which can allow listeners to distribute messages to connected clients. Or you can skip integrating the comms with the database altogether and just notify connected users completely from code when things happen.

Collapse
dmfay profile image
Dian Fay

Redis is also a possibility if your data model is pretty lightweight and the main focus is on publishing/subscribing to events.

🌚 Life is too short to browse without dark mode