← tech

// engineering

SQL vs NoSQL: What Actually Matters

A practical breakdown of when to use SQL vs NoSQL, with real-world context from working on distributed systems at scale.

|4 min read|
databasessqlnosqlarchitecturedistributed-systems

Every time SQL vs NoSQL comes up, people either default to "just use Postgres" or go full hype on NoSQL like it solves everything. The real answer depends on your architecture, your team, and what you're actually trying to solve. Here's how I think about it.

Core differences

SQL is relational. Structured tables, defined schema, ACID guarantees. Either the whole transaction succeeds or none of it does. NoSQL is flexible. Document-based, schema-free, built for distributed systems and high throughput. The trade-off is you usually get eventual consistency instead of strong guarantees.

DimensionSQLNoSQL
ConsistencyStrong, ACIDEventual (configurable)
SchemaRigid, migrations neededFlexible, evolves freely
ScalingVerticalHorizontal, built-in
Query patternsComplex joinsSimple lookups, documents
Write throughputModerateVery high
Architecture fitMonolith, small teamMicroservices, distributed
Fault toleranceActive-passiveActive-active supported

When to use each one

Use SQL when your schema is stable, you need strong consistency, and you're doing complex queries across related data. Financial systems, user accounts, order management. Also, if you're a small team or startup, just use SQL. Optimize for simplicity first.

Use NoSQL when your data structure evolves frequently, you need massive write throughput, or you're in a distributed system where teams own their data independently. At my current company, we process loyalty transactions for millions of consumers monthly using Cosmos DB, partly because the document structure changes often. With SQL, every structural change means a migration. With Cosmos DB, documents just evolve.

Don't pick NoSQL because it's modern. Don't stick with SQL because it's familiar. Understand your actual constraints, then pick the right tool.

The organizational angle

This is underrated: your database choice is often driven by team structure, not just technical requirements. One small team with one codebase? SQL is perfect. But as companies grow and split into domain teams, sharing a SQL database creates tight coupling. Team A's schema change breaks Team B. Nobody can deploy independently.

NoSQL solves this. Each domain team owns their own container, evolves their schema independently, and communicates through events. That's why at my current company, as teams reorganized around domains and adopted event-driven architecture, new services naturally moved to Cosmos DB.

How database choice tends to evolve with org size:

  • Startup: One team, one codebase, one SQL database.
  • Growing: Multiple teams, scaling pain points emerge. SQL + NoSQL in the mix.
  • Scale: Domain teams, event-driven, independent. NoSQL by default.

CAP theorem and Cosmos DB consistency

The senior-level framing for all of this is the CAP theorem. In any distributed system, you can only guarantee two of three things:

  • Consistency: Every read sees the most recent write.
  • Availability: Every request gets a response, even during failures.
  • Partition Tolerance: The system keeps working when the network between nodes fails.

Partition tolerance is non-negotiable in distributed systems. Networks fail. So you're really choosing between consistency and availability. SQL prioritizes consistency. NoSQL prioritizes availability, accepting eventual consistency in return.

Cosmos DB handles this well by letting you configure your consistency level per workload:

LevelTrade-off
StrongLatest data, slower writes
Bounded StalenessConfigurable lag window
SessionConsistent within a session
EventualFastest, converges over time

The architecture and organizational constraints drive the database choice, not trends. SQL for small teams and monoliths. NoSQL for distributed, domain-driven systems where teams need independence and schemas need to evolve.