4 · Databases: choosing & replicating · SQL vs NoSQL

SQL vs NoSQL

Relational (Postgres, MySQL)Key-value / wide-column (DynamoDB, Cassandra)Document (MongoDB)
ModelTables, joins, schemaKey → value; partition key + sort keyJSON documents
StrengthTransactions, flexible queriesMassive horizontal scale, predictable latencyFlexible nested data
WeaknessHarder to shardMust design around access patterns; few joinsJoins/transactions weaker
Pick whenDefault. Relationships, money, unknown queriesHuge write volume, simple lookups by keySelf-contained records

Default to SQL unless you can name the scale or access pattern it can't handle. 'NoSQL because it scales' is not a reason by itself.

Also know: object storage (S3) for blobs, search index (Elasticsearch) for full-text, time-series DBs for metrics. Real systems use several — polyglot persistence.