Short answer
Choose a relational (SQL) database when data is structured and related, you need joins, strong consistency and multi-row transactions. Choose a NoSQL store when access patterns are simple and known, the schema changes often, or you need to scale writes horizontally with flexible documents, key-value lookups, wide columns or graph traversal.
Families of NoSQL
- Document stores — JSON-like records, flexible schema.
- Key-value stores — very fast lookups by key, often used for caching and sessions.
- Wide-column stores — large-scale writes with query-driven table design.
- Graph databases — relationships as first-class data.
It is rarely either/or
Many systems use a relational database as the source of truth and add a cache, a search index or a document store for specific access patterns.
How to answer it in an interview
- Start from access patterns and consistency needs, not from technology preference.
- Mention that modern relational databases support JSON columns too.