Database Concepts for Modern System Design
Introduction to database:

Why do we need databases? Or even storage?
Suppose you are ordering a book from an e-commerce platform. You open the app, search for the book, and the system must fetch that information instantly. This means the application needs a place to store product data so it can be retrieved quickly when you search.
Now imagine all this data is stored in simple file storage.
What’s the issue with file storage?
File storage works for basic logs but fails when many users read or write data at the same time. You can’t control different permission for different users and many more.
Solution:
A database is a system that stores data in an organized way and provides efficient, safe, and reliable methods to retrieve and manage that data.

Advantage:
Data Consistency
Ensures the same data is uniformly available across the system, reducing duplication and contradictions.High Reliability & Durability
Databases guarantee that once data is written (especially in ACID systems), it won’t be lost even during failures.Efficient Data Retrieval
Indexing, query optimization, and caching engines allow fast reads—even for large datasets.Scalability
Modern databases support vertical & horizontal scaling, sharding, clustering, and replication.Security & Access Control
Fine-grained permissions, encryption, and auditing ensure data is protected at rest and in transit.Backup & Recovery
Built-in mechanisms allow restoring data after accidental deletion, crashes, or corruption.Concurrency Handling
Database engines manage multiple users modifying data at the same time without conflicts.Integrity Constraints
Features like primary keys, foreign keys, and unique constraints maintain correct & meaningful data relationships.Support for Transactions
Ensures reliable multi-step operations (commit/rollback) without partial updates.
There are 3 basic types of databases:
SQL: Structured Query Language databases are relational systems (RDBMS) that store data in tables with a predefined schema and structure. They enforce relationships between tables and support powerful querying using SQL.
Examples: MySQL, PostgreSQL, Oracle, SQL Server

NoSQL: Not Only SQL. NoSQL databases store data in various formats such as key–value, document, wide-column, and graph. They support flexible schemas and are highly suitable for horizontal scaling. NoSQL databases are ideal when dealing with unstructured or semi-structured data.
Examples: MongoDB, Elasticsearch, Redis, DynamoDB

NewSQL: NewSQL databases combine the relational model and SQL querying of traditional SQL databases with the horizontal scalability of NoSQL systems. They provide strong ACID consistency while being able to scale across distributed clusters.
Examples: CockroachDB, Google Spanner, TiDB.

Next, we’ll explore the major types of databases—how they work, where they fit, and why they matter in system design.


