SQL, NoSQL, schema design, indexes, transactions, replication, backups, caching and scaling.
SQL vs NoSQL
SQL databases such as PostgreSQL and MySQL are excellent for structured data with relationships: customers, orders, invoices and payments. NoSQL databases such as MongoDB are useful when records vary a lot or need flexible documents.
Transactions and Consistency
A transaction groups steps so they either all succeed or all fail. In a bank transfer, money should not leave one account unless it also reaches the other account.
Indexes
An index is like a book index. It speeds up reads by letting the database find rows without scanning everything. Indexes also add storage and can slow writes, so index the queries that matter.
Real-World Example
The app stores users, drivers, trips and payments in a relational database. A cache stores nearby driver locations for quick lookup. Analytics data moves to a warehouse so reports do not slow down live bookings.
Backups, Replication and Scaling
- Backups: protect against deletion, corruption and ransomware.
- Replication: keeps copies for availability and read scaling.
- Sharding: splits huge data across multiple machines.
- Caching: keeps frequently used data close to the app.
Beginner Checklist
- Design tables around real business objects.
- Use primary keys and foreign keys where relationships matter.
- Index common filters and joins.
- Test backup restore, not just backup creation.
- Monitor slow queries before buying bigger servers.
A good database design protects correctness first, then optimizes speed and scale.
Explore Databases