SQL databases (PostgreSQL, MySQL) use structured schemas with tables, rows, and relationships. They enforce data integrity with constraints and excel at complex joins and transactions.
NoSQL databases (MongoDB, Redis, DynamoDB) offer flexible schemas. Document stores (MongoDB) store JSON-like documents. Key-value stores (Redis) offer fast lookups. Column-family stores handle wide columns.
Choose SQL when: data has clear relationships, you need ACID transactions, complex queries with joins, or strict data integrity.
Choose NoSQL when: data is unstructured or rapidly changing, you need horizontal scaling, high write throughput, or flexible schema evolution.
Modern approach: polyglot persistence — use SQL for transactional data, Redis for caching, MongoDB for content, and Elasticsearch for search.
NewSQL (CockroachDB, TiDB) combines SQL guarantees with NoSQL scalability. They are worth evaluating for new projects.