1. Home
  2. Changelog

Apr 27, 2022

Rasmus Porsager on MongoDB vs PostgreSQL

2 min → 1:02

Overview

The speaker recounts his early programming journey, initially choosing the newer MongoDB over SQL, which he considered an "ancient" technology.

3 things to know

SQL vs. NoSQL

A practical comparison based on a developer's long-term experience, contrasting the initial ease of use of MongoDB with the long-term structural benefits of PostgreSQL.

▶ Watch at 0:13

Mongoose Library

An Object Data Modeling (ODM) library for MongoDB that allows developers to enforce schemas at the application level on top of the schemaless database.

▶ Watch at 0:46

Schemaless Databases

The core concept of document-based databases like MongoDB, which offer flexibility by not requiring a predefined data structure.

Also in this episode

Data Integrity and Maintainability

The challenge of maintaining a consistent and predictable data structure in a flexible environment over time, especially as a project is handed off between developers.

Technology Perception

How developer perceptions of "old" versus "new" technologies can influence architectural decisions, sometimes overlooking the proven benefits of established tools like SQL.

Quotes

“I thought it was this ancient thing that wasn't a good idea to use anymore.”

▶ Watch at 0:13

“So the entire idea behind Mongo being schemaless and document-based, I wasn't using it at all for anything.”

▶ Watch at 0:46

“Why haven't I given this a shot before?”

▶ Watch at 2:14

Full summary

Episode Overview

  • The speaker recounts his early programming journey, initially choosing the newer MongoDB over SQL, which he considered an "ancient" technology.
  • He discusses his "aha" moment: while using the Mongoose library, he realized he was building schemas on top of a schemaless database, thereby nullifying its core benefit.
  • The speaker shares a negative experience where a system he built on MongoDB lost its structural integrity after being handed off to a new team.
  • This experience, combined with the growing popularity of Postgres around 2016, led him to switch, and he has been a strong advocate for it ever since.

Key Concepts

  • SQL vs. NoSQL: A practical comparison based on a developer's long-term experience, contrasting the initial ease of use of MongoDB with the long-term structural benefits of PostgreSQL.
  • Mongoose Library: An Object Data Modeling (ODM) library for MongoDB that allows developers to enforce schemas at the application level on top of the schemaless database.
  • Schemaless Databases: The core concept of document-based databases like MongoDB, which offer flexibility by not requiring a predefined data structure.
  • Data Integrity and Maintainability: The challenge of maintaining a consistent and predictable data structure in a flexible environment over time, especially as a project is handed off between developers.
  • Technology Perception: How developer perceptions of "old" versus "new" technologies can influence architectural decisions, sometimes overlooking the proven benefits of established tools like SQL.

Quotes

  • At 00:13 - "I thought it was this ancient thing that wasn't a good idea to use anymore." - The speaker explains his initial perception of SQL when he was a new programmer, favoring the novelty of MongoDB.
  • At 00:46 - "So the entire idea behind Mongo being schemaless and document-based, I wasn't using it at all for anything." - He describes his realization that using the Mongoose library to create schemas meant he was effectively fighting against, rather than leveraging, MongoDB's core design philosophy.
  • At 02:14 - "Why haven't I given this a shot before?" - His thought after finally exploring PostgreSQL and discovering the directness and power of using SQL for creating structured tables, which he found more suitable for his needs.

Takeaways

  • Be mindful of defeating the purpose of your tools; if you find yourself enforcing rigid schemas on a schemaless database, consider whether a relational database like Postgres is a more appropriate choice from the start.
  • Prioritize long-term maintainability over initial setup speed. A database with enforced structural integrity can prevent data chaos and be easier for future teams to understand and build upon.
  • Re-evaluate established technologies periodically. "Old" technologies like SQL have remained relevant for decades because they solve a fundamental set of problems effectively and reliably.

Watch the full episode 2 min

Read along with the audio summary

The speaker once dismissed SQL as an ancient technology that was not a good idea to use anymore, choosing the newer MongoDB instead. In this episode, which came out on April 27, 2022, a software developer shares his early programming journey. By the end, you will learn how to choose between initial setup speed and long term database structure.

Why initial ease of use can lose to long term structure. A developer's long term experience contrasts the easy start of MongoDB, a NoSQL database, with the lasting structural benefits of PostgreSQL, a SQL database. Around 2016, the growing popularity of Postgres and its direct power for creating structured tables led the speaker to switch and become a strong advocate.

How an add on tool can defeat your database's purpose. The speaker had an aha moment while using Mongoose, an Object Data Modeling library that enforces rules called schemas at the application level. He realized that by building schemas on top of a schemaless database, he was nullifying its core benefit. If you find yourself enforcing rigid schemas on a schemaless database, consider whether a relational database like Postgres is a more appropriate choice from the start.

The hidden trap of total flexibility. Document based databases like MongoDB offer flexibility because they are schemaless, meaning they do not require a predefined data structure. Yet because the speaker was adding schemas anyway, he was not using that document based, schemaless design for anything at all.

What happens when a flexible project changes hands. Maintaining a consistent and predictable data structure in a flexible environment is a challenge over time. The speaker built a system on MongoDB that lost its structural integrity after being handed off to a new team. Prioritize long term maintainability over initial setup speed so future teams can understand and build upon your database without data chaos.

Why newer is not always better in software. Developer perceptions of old versus new tools can influence architectural decisions and overlook the proven benefits of established tools like SQL. After finally exploring PostgreSQL, the speaker wondered why he had not given it a shot before.

Be mindful of defeating the purpose of your tools. Reevaluate established technologies like SQL periodically, because they have remained relevant for decades by solving a fundamental set of problems effectively and reliably.

More from Changelog

Related Episodes