Full answer
The honest answer starts with the access pattern, not with a brand name.
A relational database fits when:
- Entities relate to each other: customers have orders, orders have items, items reference products.
- You need the database to enforce rules: foreign keys, unique emails, CHECK constraints.
- A business action changes several rows at once and must be all-or-nothing, such as moving stock and creating an order.
- You do not know every question in advance. SQL lets an analyst join and group the same data in new ways next month.
A document store such as MongoDB fits when:
- Each record is loaded and saved as a whole, like a user's settings or a product page with a varying set of attributes.
- Different records legitimately have different fields.
- Queries almost always fetch by one key, and cross-record reporting is rare or done in a separate system.
The cost of a document model shows up when the access pattern changes. If orders are embedded inside customer documents, a report of "all orders last week across all customers" becomes awkward, and data duplicated across documents has to be kept in sync by application code.
The line is also less sharp than it used to be. PostgreSQL stores and indexes JSON (the jsonb type), and many document stores now offer multi-document transactions. A common, sensible setup is a relational database as the source of truth, with a cache, a search index or a document store added for a specific read pattern.
Key points
- Start from the access pattern and the consistency needs
- Relational: relationships, constraints, multi-row transactions, ad-hoc questions
- Document: self-contained records, varying shape, key-based access
- PostgreSQL jsonb blurs the line for semi-structured fields
Common mistakes
- Choosing a document store because the schema is not designed yet
- Claiming NoSQL is always faster or always scales better
Follow-ups
- How would you store product attributes that differ by category in PostgreSQL?
- What does eventual consistency mean for a user-facing feature?
Tips
- Tie the choice to one concrete feature, such as an order checkout or a settings page
- Avoid absolute claims about speed; talk about access patterns