Full answer
Relational (SQL)
Data lives in tables with typed columns. Relations are expressed with foreign keys and queried with joins. Transactions are ACID: a fee payment and the receipt row are saved together or not at all. You can ask new questions later ("average score by school by subject") without redesigning storage. Examples: PostgreSQL, MySQL, SQL Server.
NoSQL families
| Type | Model | Good for | Examples |
|---|---|---|---|
| Key-value | key -> blob | Sessions, caches, feature flags | Redis, DynamoDB (also document) |
| Document | JSON-like documents | Records read as a whole, varied fields | MongoDB, Firestore |
| Wide-column | Rows with many columns grouped by partition key | Huge write volume, time series, messages | Cassandra, ScyllaDB, Bigtable |
| Graph | Nodes and edges | Relationship traversal | Neo4j |
Many NoSQL stores are designed around a known access pattern: you model data for the queries you will run. That makes them fast and easy to scale out for those queries, and awkward for unplanned ones.
Myths to avoid
- "NoSQL has no schema." The schema still exists; it lives in application code instead of the database.
- "SQL cannot scale." Relational databases handle very large loads with replicas, partitioning and sharding tools, and distributed SQL databases scale horizontally.
- "NoSQL is never transactional." MongoDB and DynamoDB support transactions with limits.
How to decide
Ask:
- Is the data relational with many joins (students, courses, enrolments, payments)? Start with SQL.
- Do you need multi-row transactions and constraints? SQL.
- Is the access pattern simple and known, with very high write volume (chat messages by conversation, sensor readings by device)? A wide-column or key-value store fits.
- Do records have very different shapes (product catalogue with category-specific fields)? Document store, or SQL with a JSON column.
Most products use both: PostgreSQL as the system of record, Redis for caching and sessions, perhaps Cassandra or a time-series store for one high-volume stream.
By level
Fresher: Explain tables, joins and transactions versus key-value and document stores, with one example use for each. Choosing SQL for payments and explaining why is a good test at this level.
Mid: Model one entity both ways, explain access-pattern-driven design and the transaction and consistency differences. Expect one entity modelled both relationally and for a NoSQL store.
Senior: Discuss polyglot persistence costs, data migration between stores, distributed SQL options, operational maturity, and how consistency and query flexibility affect long-term product changes. The answer should consider the long-term cost of running several kinds of database.
Key points
- SQL: tables, joins, ACID transactions, ad hoc queries
- NoSQL is several models: key-value, document, wide-column, graph
- NoSQL often designs storage around known queries
- Schema-less really means schema in application code
- Many systems combine both
Common mistakes
- Saying SQL cannot scale
- Choosing NoSQL only because the schema "might change"
- Ignoring the need for transactions in payments or inventory
- Treating all NoSQL databases as the same
Follow-ups
- How would you model chat messages in Cassandra?
- When would a JSON column in PostgreSQL beat a document database?
- What does it cost to add a new query pattern to a key-value design?
Tips
- Name the four NoSQL families with one example each
- Decide from access patterns, not trends
- Mention that combining stores is normal
Evaluation rubric
- Accurate description of relational strengths
- Knows the NoSQL families and their fits
- Corrects at least one common myth
- Gives a decision process tied to requirements