Advanced Database Concepts
6. Advanced Database Concepts
a. Database Design
Database design is about structuring data so it is easy to store, retrieve, and maintain over time. At a high level, this means identifying entities (like users, orders, products), their attributes, and the relationships between them. A good design starts from the real-world domain and then maps that understanding into tables and columns instead of jumping straight into SQL. Thoughtful design reduces duplication, avoids inconsistencies, and makes later changes easier.
A key concept in relational design is normalization, which is the process of organizing tables to reduce redundancy. For example, instead of storing the same customer address in multiple tables, you store it in one place and reference it with keys. Over-normalizing can cause too many joins and hurt performance, so in practice teams balance normalization with denormalization based on read/write patterns and query needs.
b. Indexing
Indexing is a performance technique that speeds up queries by creating additional data structures that help the database locate rows quickly. An index is similar to a book’s index: instead of scanning every page, you jump directly to where the topic appears. Without indexes, the database might have to scan entire tables for many queries, which becomes slow as data grows.
Commonly, indexes are created on columns that appear in WHERE clauses, JOIN conditions, and ORDER BY operations. While indexes speed up reads, they add overhead to writes because the index structures must be updated when data changes. As a result, indexing is a trade‑off: you want enough indexes to support critical queries but not so many that inserts and updates become expensive.
c. Transactions
A transaction is a group of database operations that are treated as a single unit of work. Either all operations in the transaction succeed, or none of them take effect. The classic example is moving money between accounts: you must subtract from one account and add to another; failing halfway would leave data inconsistent. Transactions are governed by the ACID properties: Atomicity, Consistency, Isolation, and Durability.
Isolation levels in transactions control how concurrent operations see each other’s changes. Higher isolation reduces anomalies like dirty reads but can increase locking and contention. In practice, systems choose an isolation level that balances correctness and performance based on business requirements. Understanding transactions is essential for building reliable systems that handle concurrent updates safely.
d. NoSQL Databases
NoSQL databases are a family of data stores that move away from strict relational tables and schemas. They include document stores, key–value stores, wide‑column stores, and graph databases. These systems often trade some relational features (like complex joins) for scalability, flexibility, and different data models. They are commonly used when data structures are evolving, when scale is high, or when performance characteristics differ from traditional OLTP workloads.
Each type of NoSQL database fits different use cases. Document stores work well for JSON‑like data that changes shape over time. Key–value stores shine in caching and simple lookup scenarios. Wide‑column databases support high‑throughput analytical workloads. Graph databases excel at highly connected data, like social networks or recommendation graphs. The choice between relational and NoSQL is rarely about “better vs worse” and more about matching the data model and access pattern.
Relational vs NoSQL (High-Level)
Aspect | Relational Databases | NoSQL Databases |
| Data model | Tables, rows, fixed schema | Documents, key–value, columns, graphs |
| Schema changes | More rigid, migrations needed | Often flexible or schema-less |
| Joins | First-class, powerful | Limited or handled in application logic |
| Consistency | Strong consistency by default | Often tunable, sometimes favor eventual |
| Typical use cases | OLTP, structured business data | High scale, flexible or unstructured data |










