ποΈ Welcome to Databases
What is a database?β
A database is an organized system for efficiently storing, managing, and retrieving information.
It allows you to save structured data that can be queried, updated, or deleted according to the needs of an application.
A database is not just a giant spreadsheet. It uses specialized models, languages, and structures to handle data robustly and securely.
β Why use a database?β
- Allows handling large volumes of information
- Facilitates concurrent data access
- Ensures integrity, consistency, and security
- Essential in modern applications (web, mobile, enterprise)
Types of databasesβ
- Relational (SQL): use tables and relationships (PostgreSQL, MySQL, SQLite, MariaDB)
- Non-relational (NoSQL): more flexible inherently (MongoDB, Redis, Cassandra, etc.)
- Distributed: data distributed across multiple servers (CockroachDB, Cassandra)
- In-memory: optimized for speed (Redis, Memcached)
π SQL vs NoSQLβ
| Feature | SQL (Relational) | NoSQL (Non-relational) |
|---|---|---|
| Structure | Tables | Documents, Key-Value, etc. |
| Query language | SQL | Varies (Mongo Query, etc.) |
| Scalability | Vertical | Horizontal |
| Consistency | High (ACID) | Eventual (BASE) |
NoSQL does not replace SQL. Each type is better suited depending on the use case: structure, scalability, relationship complexity, etc.
Common database use casesβ
- Storing users, products, events, logs
- Managing relationships between data (users and their orders)
- Querying filtered or grouped information
- Data persistence between sessions