Databases & Transactions interview question · Most asked
How do you choose between SQL and NoSQL databases?
Summary
Choose relational (PostgreSQL, MySQL) for structured data with relationships, transactions and flexible querying; choose NoSQL for specific access patterns: document stores (MongoDB) for flexible nested documents, key-value/wide-column (DynamoDB, Cassandra) for massive scale with known queries, graph databases for relationship traversal, and search engines for full-text search.
Longer Answer
Start from access patterns, consistency needs, scale and team expertise. Postgres covers many 'NoSQL' needs (JSONB, full-text search, extensions). Polyglot persistence is common: a relational source of truth plus Redis, a search index and an analytics store.
Key Points
- Relational: transactions + flexible queries
- Document: flexible nested data
- KV/wide-column: scale with known access
- Start from access patterns
- Polyglot persistence
More most-asked Databases & Transactions questions
- What does ACID mean?
- Explain transaction isolation levels and the anomalies they prevent.
- How do database indexes work and when do they help or hurt?
- What is the N+1 query problem and how do you fix it?
- What is connection pooling and how do you size a pool?
- How do you run schema migrations without downtime?
- How do you keep data consistent across services without distributed transactions?