All questions
CS Fundamentals

SQL vs NoSQL: when to use which?

SQL (relational) databases store data in tables with a fixed schema and relationships, support powerful joins, and provide ACID transactions. They are the right default when data is structured and relationships and strong consistency matter — financial records, orders, anything transactional.

NoSQL databases cover several models: document (MongoDB), key-value (Redis, DynamoDB), wide-column (Cassandra), and graph. They typically offer flexible or schemaless data, horizontal scaling across many nodes, and high write throughput, often trading strict consistency for availability and partition tolerance.

Choose SQL when you need complex queries, joins, and transactional integrity, and your scale fits a (possibly sharded) relational system. Choose NoSQL when you need to scale writes massively, your access patterns are simple and known up front, or your data is naturally document- or key-based. In an interview, avoid declaring one universally better — frame it by the access pattern, consistency needs, and scale of the specific problem.

Practise this live with NostrobeAI

Get real-time, structured guidance for coding, system design, and behavioral interviews. Free trial, no subscription.

Download Free Trial