The CAP theorem, BASE, and when to reach for a non-relational database
NoSQL databases exist because relational databases make trade-offs that don't suit every use case — rigid schemas, expensive joins at scale, difficulty sharding. Understanding the CAP theorem and the different NoSQL data models lets you make deliberate technology choices rather than defaulting to Postgres for everything or blindly reaching for MongoDB.
The CAP theorem states that a distributed system can guarantee at most two of: Consistency (every read sees the latest write), Availability (every request gets a response), and Partition tolerance (the system works despite network splits). Since network partitions are a reality, the real choice is C vs A: be consistent but potentially unavailable during a partition, or always available but potentially stale.
Relational databases prioritize Consistency. Many NoSQL databases prioritize Availability, embracing BASE: Basically Available, Soft state, Eventually consistent.