Skip to content

Databases

This content is for Backend. Switch to the latest version for up-to-date documentation.

A Database is an organized collection of data, so that it can be easily accessed and managed.

SQL (Structured Query Language) databases store data in tables (like Excel sheets) with rows and columns. They are good for structured data and complex queries.

PostgreSQL (or Postgres) is an advanced, open-source object-relational database system.

  • Reliable: Known for data integrity and correctness.
  • Features: Supports JSON, complex queries, and custom types.
  • ACID Compliant: Ensures transactions are processed reliably (Atomicity, Consistency, Isolation, Durability).

For a deeper, practical guide with raw SQL examples (constraints, indexes, joins, transactions, JSONB), see:

Diagram
  • MySQL: Very popular, powers WordPress.
  • MariaDB: A popular MySQL-compatible fork.
  • SQLite: A file-based database. Good for small apps or mobile.
  • Oracle: Enterprise database (often used in large organizations).
  • Microsoft SQL Server: Enterprise database (common in Windows/.NET environments).

NoSQL databases do not use tables. They might use documents (JSON), key-value pairs, or graphs.

  • MongoDb: Stores data like JSON documents. Flexible schema.
  • Redis: In-memory key-value store. Very fast. Often used for Caching.
  • Normalization: Organizing data to reduce redundancy (duplicates).
  • Transactions: A group of operations that either all succeed or all fail.
  • Indexing: A way to speed up searching in a database (like the index at the back of a book).

Replication means keeping copies of your data across multiple machines.

  • Improves availability (if one node goes down, another can serve reads).
  • Can improve read performance.

Sharding splits a large dataset into smaller parts (shards) across multiple databases/servers.

  • Improves horizontal scalability.
  • Adds complexity (routing queries, rebalancing shards).
Built with passion by Ngineer Lab