Skip to content
Devgo

Database

A system for storing, querying, and managing structured data. Every app needs one. Relational databases (PostgreSQL, MySQL) use tables and SQL. NoSQL databases (MongoDB, DynamoDB) use documents or key-value. The foundation of any backend.

When to use
  • Any app that stores data persistently.
  • When you need queries, relationships, or transactions.
When not to
  • Ephemeral data (use memory/cache).
  • Blob storage (use object storage).

Definition

A database stores data persistently and lets you query, insert, update, and delete it. Relational () databases enforce schemas and relationships. databases are more flexible (document, key-value, graph, column). properties guarantee transaction safety.

Why it exists

To store data persistently, query it efficiently, handle concurrent access, and ensure consistency — things you can't do reliably with files.

How it works

You define a schema (tables/collections), insert data, and query it ( or API). The database manages storage, indexing, concurrency, and transactions. Indexes speed up queries. A connection pool manages client connections. Backups and ensure durability.

Scaling limits

Single-server databases hit CPU/memory/disk limits. Vertical scaling (bigger machine) is easy but finite. Horizontal scaling (sharding, ) is complex. Connection limits. Query performance on large tables.

Cost shape

Self-hosted (free, you manage) or managed (RDS, — pay per usage/storage/IO).

Alternatives

  • Files — Simple but no queries, concurrency, or consistency.
  • In-memory cache — Fast but volatile — data lost on restart.

Failure modes

  • Data loss from no backups.
  • Slow queries from missing indexes.
  • Lock contention.
  • Schema drift.

, , , , ,