Is Relational Database Always the Right Choice? Exploring Modern Database Architectures

2 hours ago 3
Club.noww.in

  

Relational databases have been the backbone of enterprise software for decades. MySQL, PostgreSQL, and SQL Server power everything from small applications to large-scale enterprise platforms.

 

They offer ACID transactions, structured schemas, powerful querying capabilities, and mature ecosystems.

 

But modern applications have changed significantly. We now deal with billions of events, massive user-generated content, real-time analytics, highly interconnected data, and globally distributed workloads.

 

Can one database model efficiently handle all these requirements?

The answer is not necessarily.

 

Rather than asking which database is the most powerful, architects need to ask a more important question:

 

Does the database model match the way our application stores, accesses, and processes data?

 

Let's explore the limitations of relational databases, the different database models available today, and how to make the right architectural choice.

 

1. Why Relational Databases Became the Default Choice

Before exploring alternative database technologies, it is important to understand why relational databases became the foundation of modern software development in the first place.

 

For decades, relational database management systems (RDBMS) have been the preferred choice for building enterprise applications. Whether it is a banking application processing financial transactions, an e-commerce platform managing orders, or an enterprise system maintaining employee records, relational databases have been at the center of these systems.

 

Technologies such as MySQL, PostgreSQL, Microsoft SQL Server and Oracle Database have earned this position because they provide something fundamental: a structured and reliable way to store, manage, retrieve, and maintain data.

 

But what exactly makes a relational database different?

 

1.1 What Is a Relational Database?

A relational database is a database management system that organizes data into structured tables consisting of rows and columns.

 

The relational model was introduced by Edgar F. Codd in 1970. Its central idea was simple but powerful: represent data as relations (tables) and use well-defined rules to establish relationships between different sets of data.

 

Instead of storing all application information in a single large structure, data is divided into logical entities and stored in separate tables.

 

Consider an e-commerce application. It needs to manage customers, products, orders, and payments.

 

We can represent this information using separate tables:

 

Customers table

customer_id

name

email

101

John

john@example.com

102

Sarah

sarah@example.com

103

David

david@example.com

                 

Products table

product_id

product_name

price

501

Laptop

75000

502

Mobile

25000

503

Keyboard

2000

 

Orders table

order_id

customer_id

order_date

1001

101

2026-11-20

1002

102

2026-11-21

1003

101

2026-11-22

 

Order_Items table

order_item_id

order_id

product_id

quantity

1

1001

501

1

2

1001

503

2

3

1002

502

1

 

Notice that customer information, product information, and order information are maintained separately. This avoids unnecessary duplication and allows the application to establish meaningful relationships between different entities.

1.2 Understanding Tables, Rows, Columns, and Relationships

To understand the relational model, let's look at its fundamental building blocks.

 

Tables

A table represents a logical entity in the application.

 

Examples:

- Customers

- Products

- Orders

- Employees

- Payments

 

Each table represents a specific type of information.

 

Rows

A row represents an individual record within a table. For example, a row in the Customers table represents one customer, while a row in the Orders table represents one order.

 

Columns

Columns define the attributes of an entity.

 

For example, a Customers table might contain:

- customer_id

- name

- email

- phone_number

- created_at

 

Each column has a defined data type, such as INTEGER, VARCHAR, DATE, or DECIMAL.

 

Primary Keys

A primary key uniquely identifies each record in a table. For example, customer_id uniquely identifies a customer.

 

Foreign Keys

A foreign key establishes a relationship between two tables by referencing a key in another table. For example, customer_id in the Orders table references customer_id in the Customers table.

 

This allows the database to maintain relationships between entities without repeatedly storing the complete customer information in every order.

 

Relationships

Relational databases support three common types of relationships:

 

Relationship

Example

One-to-One

Employee and employee profile

One-to-Many

One customer can place multiple orders

Many-to-Many

Products can belong to multiple categories

 

Many-to-many relationships are typically represented using an intermediate junction table.

 

For example, an order can contain multiple products, and a product can appear in multiple orders. The Order_Items table establishes this relationship.

 

1.3 SQL: The Language of Relational Databases

One of the biggest reasons relational databases became popular is SQL (Structured Query Language).

 

SQL provides a standard and declarative way to interact with structured data.

 

Instead of writing code to determine how records should be located, developers describe what data they want, and the database query optimizer determines an execution strategy.

 

For example, consider retrieving all orders placed by a particular customer:

SELECT o.order_id, o.order_date, c.name AS customer_name FROM Orders o JOIN Customers c ON o.customer_id = c.customer_id WHERE c.customer_id = 101;

The database joins the Orders and Customers tables using their relationship and returns the matching records. SQL supports several important operations:

 

Operation

Purpose

Example

SELECT

Retrieve data

Fetch customer details

INSERT

Insert records

Create a new order

UPDATE

Modify records

Update order status

DELETE

Remove records

Delete an obsolete record

JOIN

Combine related data

Fetch customer orders

GROUP BY

Aggregate data

Calculate sales by region

ORDER BY

Sort results

Show latest orders

 

Another important capability is that SQL allows developers to perform complex filtering, aggregation, sorting, and joins without implementing all these operations in application code.

 

This makes relational databases particularly useful for applications where data relationships and query requirements are important.             

 

1.4 ACID Transactions: Ensuring Data Reliability

One of the strongest reasons enterprises trust relational databases is their support for ACID transactions.

 

ACID stands for:

- Atomicity

- Consistency

- Isolation

- Durability

 

These properties help ensure that database transactions execute reliably, even when failures or concurrent operations occur.

 

Let's understand them using a simple banking example.

 

Imagine transferring ₹10,000 from Account A to Account B.

 

The operation involves two updates:

-       Deduct ₹10,000 from Account A.

-       Add ₹10,000 to Account B.

 

Both operations must succeed together. If one succeeds and the other fails, the account balances become incorrect.

 

Let's understand how ACID makes this possible.

 

a. Atomicity – All or Nothing

A transaction is treated as a single logical unit. Either both account updates succeed, or neither update is applied.

 

BEGIN TRANSACTION; UPDATE Accounts SET balance = balance - 10000 WHERE account_id = 'A'; UPDATE Accounts SET balance = balance + 10000 WHERE account_id = 'B'; COMMIT;

If an error occurs before the commit, the transaction can be rolled back.

 

b. Consistency – Maintain Data Integrity

A transaction must move the database from one valid state to another valid state, respecting defined constraints and business rules.

 

For example:

- Account balance must not become negative if the application enforces that rule.

- Customer IDs referenced by orders must exist.

- Unique constraints must not be violated.

 

c. Isolation – Handle Concurrent Transactions

Multiple users may access and modify the same database simultaneously.

 

Isolation ensures that concurrent transactions do not interfere in ways that violate the database's configured isolation guarantees.

 

For example, if two users attempt to withdraw money from the same account simultaneously, the database must coordinate those operations to prevent incorrect balances.

 

Different isolation levels provide different guarantees and performance trade-offs.

 

d. Durability – Committed Data Survives Failures

Once a transaction is committed, its changes are expected to survive system crashes or restarts, using mechanisms such as transaction logs and persistent storage.

 

This is especially important in financial applications, where losing committed transactions is unacceptable.

 

1.5 Referential Integrity: Keeping Relationships Consistent

Another important capability of relational databases is referential integrity. Referential integrity ensures that relationships between tables remain valid.

 

Consider an Orders table containing a customer_id that references the Customers table. What happens if someone attempts to create an order for a customer who does not exist?

A relational database can prevent this using a foreign key constraint.

CREATE TABLE Orders ( order_id INT PRIMARY KEY, customer_id INT NOT NULL, order_date DATE, CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES Customers(customer_id) );

Now, the database ensures that an order cannot reference a nonexistent customer.

 

Similarly, it can enforce:

- Primary key constraints.

- Foreign key constraints.

- Unique constraints.

- NOT NULL constraints.

- CHECK constraints.

 

These constraints move important data integrity rules into the database itself instead of relying entirely on application-level validation.

 

This is particularly valuable in enterprise systems where multiple applications, services, or users may interact with the same underlying data.

 

1.6 Why RDBMS Became the Foundation of Enterprise Applications

Relational databases became the default choice not because they were the only way to store data, but because they provided a strong combination of reliability, consistency, flexibility, and developer productivity.

 

Several characteristics contributed to their widespread adoption.

 

a. Strong Data Consistency

ACID transactions and integrity constraints make relational databases suitable for systems where correctness is critical.

 

Banking, payment processing, inventory management, and order processing are common examples.

 

b. Powerful Querying Capabilities

SQL allows developers to retrieve and manipulate data using filtering, joins, aggregations, subqueries, and window functions.

 

This makes it possible to support complex business requirements without building every data operation in application code.

 

c. Mature Ecosystem

Relational databases have decades of investment behind them.

 

They provide:

- Mature drivers and programming libraries.

- Database administration tools.

- Backup and recovery mechanisms.

- Monitoring and performance optimization.

- Replication and high-availability solutions.

- Well-established security and access-control mechanisms.

 

d. Structured Data and Data Integrity

Schemas, constraints, and relationships help maintain predictable data structures. This becomes increasingly important as enterprise applications grow and multiple teams interact with shared datasets.

 

e. Established Developer Knowledge

SQL is widely understood across the software industry.

 

Developers, database administrators, data engineers, and architects are familiar with relational concepts, making development, hiring, maintenance, and onboarding easier.

 

f. Proven Scalability

Relational databases support several scalability techniques:

- Vertical scaling: Adding CPU, memory, and storage resources.

- Read replicas: Distributing read traffic across database replicas.

- Partitioning: Dividing large tables into manageable segments.

- Sharding: Distributing data across multiple database servers.

 

Although these techniques introduce additional complexity, they demonstrate that relational databases are not limited to small applications or single-server deployments.

 

In summary, Relational databases became the foundation of enterprise software because they solved several fundamental engineering problems: structured data management, reliable transactions, data integrity, and powerful querying.

 

They remain an excellent choice for applications with well-defined data structures, transactional requirements, and complex relationships.

 

However, as applications evolve, their data structures, access patterns, and scalability requirements may change.

 

Sometimes, the challenge is no longer simply storing structured records in tables. It may involve handling massive write volumes, flexible data structures, deeply interconnected relationships, or globally distributed workloads.

 

And that brings us to the next question: What are the signs that your relational database is no longer the best fit for your application?

 

2. When Do Relational Databases Start Showing Limitations?

Relational databases are powerful, reliable, and capable of supporting applications at enormous scale. However, being a mature technology does not mean they are the best fit for every data model or workload.

 

As applications evolve, their data structures become more complex, data volumes increase, and access patterns change. What initially started as a clean relational schema can gradually become difficult to maintain and optimize.

 

For example, consider an e-commerce application that initially supports a few hundred products. A traditional relational model with Products, Categories, Customers, and Orders tables works perfectly well.

 

Now imagine that the same application grows to support millions of products across multiple categories, with each product having different attributes, millions of customer interactions, real-time inventory updates, and large-scale analytical requirements.

 

The original database design may start showing limitations, not necessarily because the relational database is incapable, but because the application's data model and workload are no longer a natural fit for the way the data is structured and accessed.

 

Let's explore some common warning signs.

 

2.1 Sparse Tables and Frequently Changing Schemas

One of the first signs of a mismatch between the data model and the relational structure is the presence of sparse tables.

 

A sparse table contains a large number of columns, but most records use only a small subset of those columns. Consider an e-commerce platform selling different types of products.

 

A laptop might have attributes such as:

- Processor

- RAM

- Storage

- Screen Size

- Graphics Card

 

A mobile phone might have:

- Screen Size

- Battery Capacity

- Camera Resolution

- Operating System

- Processor

 

A refrigerator might have:

- Capacity

- Energy Rating

- Number of Doors

- Defrost Type

 

If we attempt to represent all these product types using a single relational table, we might end up with something like this:

 

Products table

product_id

name

processor

RAM

storage

battery

camera

capacity

101

Laptop

Intel i7

16GB

512GB

NULL

NULL

NULL

102

Mobile

Snapdragon

8GB

256GB

5000mAh

50MP

NULL

103

Refrigerator

NULL

NULL        

NULL

NULL

NULL

350L

 

Notice that most columns are irrelevant for many records.

 

This introduces several challenges:

-       Wasted storage and metadata: Many attributes are not applicable to a given product type. Although database engines can optimize NULL storage, the schema still carries unnecessary complexity.

-       Schema maintenance: Introducing a new product type may require additional columns.

-       Application complexity: Application code needs to understand which attributes are applicable to each product category.

-       Query complexity: Queries may require extensive NULL handling and conditional logic.

-       One possible relational solution is to create separate tables for each product category or use a common Products table with specialized detail tables.

 

However, as the number of product types and attributes grows, maintaining these structures can become increasingly complicated.

 

When does this become a problem?

When the application frequently introduces new entity types or attributes, and the relational schema requires continuous modifications just to accommodate changes in the underlying business model.

 

A document database may be a better fit when each product naturally contains a different set of attributes.

 

For example, a document representation could look like this:

{ "productId": 101, "name": "Laptop", "category": "Electronics", "attributes": { "processor": "Intel i7", "ram": "16GB", "storage": "512GB" } }

   

A mobile phone could have a completely different set of attributes without requiring changes to a shared table structure.

 

Note: Relational databases can also handle flexible attributes using JSON columns, separate subtype tables, or other modeling techniques. A sparse table alone is not a reason to migrate to NoSQL.

 

2.2 Entity-Attribute-Value (EAV) Patterns

Another common sign of relational schema limitations is the extensive use of the Entity-Attribute-Value (EAV) model.

 

EAV is a data modeling technique used when entities have highly variable attributes that are difficult to represent using conventional columns.

 

Instead of creating a separate column for every possible attribute, the application stores each attribute as an individual record.

 

Consider the same e-commerce product catalog.

 

Instead of maintaining a wide Products table, we could use three tables:

 

Products table

product_id

name

101

Laptop

102

Mobile

 

Attributes table

attribute_id

attribute_name

1

Processor

2

RAM

3

Battery

 

        

Product_Attributes table

product_id

attribute_id

attribute_value

101

1

Intel i7

101

2

16GB

102

1

Snapdragon

102

3

5000mAh

 

 

 

 

This design allows new attributes to be introduced without modifying the database schema.

 

For example, adding a new attribute called Camera Resolution requires inserting an attribute record and its corresponding values, rather than executing an ALTER TABLE statement.

 

At first, this looks like a very flexible solution. However, it introduces another set of challenges.

 

Why can EAV become problematic?

 

Imagine that a business requirement asks for all products having:

-       RAM greater than 8GB.

-       Storage greater than 256GB.

-       A specific processor.

In a conventional relational model, this might be a relatively straightforward query.

 

With EAV, the database must retrieve and compare multiple attribute records, often requiring several self-joins or conditional aggregation.

 

For example:

 

SELECT p.product_id FROM Products p JOIN Product_Attributes ram ON p.product_id = ram.product_id JOIN Product_Attributes storage ON p.product_id = storage.product_id WHERE ram.attribute_id = 2 AND storage.attribute_id = 4;

   

The example illustrates the need to join the attribute table multiple times. In practice, numeric values also need proper typing and validation rather than being stored indiscriminately as strings.

 

As the number of attributes and filtering conditions increases, queries can become difficult to write, optimize, and maintain.

 

Other challenges include:

-       Maintaining data types for different attribute values.

-       Enforcing mandatory attributes.

-       Validating attribute-specific business rules.

-       Indexing frequently queried attributes.

-       Aggregating and reporting across dynamic attributes.

 

When does this become a problem?

When EAV becomes the primary representation for most application data, and almost every business query requires multiple joins against attribute-value tables.

 

EAV is not inherently bad. It is useful for genuinely dynamic attributes, metadata, and configurable forms. The problem arises when it becomes the default model for data that has well-defined structure.

 

A document database may provide a more natural representation when entities have many optional or evolving attributes that are commonly retrieved together.

 

2.3 Complex Joins and Hierarchical Relationships

Relational databases are designed to represent relationships between entities. In fact, this is one of their biggest strengths.

 

However, applications sometimes evolve into models with deeply interconnected data or relationships that need to be traversed dynamically.

 

Consider an organization with the following employee hierarchy:

 

- CEO

 - Engineering Director

  - Engineering Manager

    - Senior Engineer

      - Software Engineer

 

In a relational database, this can be represented using a self-referencing table.

employee_id

employee_name

manager_id

1

John 

NULL

2

Sarah

1

3

David

2

4

Alex

3

5

Michael

4

 

Here, manager_id references another employee in the same table. This is a perfectly valid relational design.

 

However, consider a requirement, "Find all employees who report directly or indirectly to John."

 

The database needs to traverse the hierarchy recursively. In SQL, this can be implemented using a recursive Common Table Expression (CTE).

 

WITH EmployeeHierarchy AS ( SELECT employee_id, employee_name, manager_id FROM Employees WHERE employee_id = 1 UNION ALL SELECT e.employee_id, e.employee_name, e.manager_id FROM Employees e JOIN EmployeeHierarchy h ON e.manager_id = h.employee_id ) SELECT * FROM EmployeeHierarchy;

   

For relatively simple hierarchies, this works well.

 

But consider more complex scenarios:

- Finding all possible connections between two users.

- Identifying mutual friends in a social network.

- Discovering relationships across multiple levels.

- Finding the shortest path between two entities.

- Detecting suspicious transaction networks.

 

These queries may involve traversing an unpredictable number of relationships.

 

As relationship depth and complexity increase, relational queries can become difficult to maintain and optimize. This is where graph databases become particularly useful.

 

Unlike relational databases, which represent relationships through foreign keys and joins, graph databases treat relationships as first-class elements of the data model.

 

For example, in Neo4j, we can represent employees as nodes and reporting relationships as edges.

 

A traversal can then follow the relationships directly.

 

When does this become a problem?

When the primary application requirement is repeatedly exploring complex, multi-level, or variable-length relationships rather than retrieving records through predictable joins.

 

Graph databases can be a better choice for these workloads, although relational databases remain perfectly capable of handling many hierarchical and relationship-based queries.

 

2.4 Storing JSON/XML Inside Relational Database Columns

As applications become more dynamic, developers often encounter situations where the data structure does not fit neatly into predefined relational columns.

 

One common solution is to store structured data such as JSON or XML inside a single database column. Most modern relational databases, including PostgreSQL, MySQL, and SQL Server, provide support for JSON data in different forms.

 

Consider an application that manages customer profiles. Initially, the customer table might contain:

customer_id

name

email

101

John 

john@example.com

102

Sarah

sarah@example.com

 

 

Over time, the application needs to store additional information:

- Communication preferences.

- Address details.

- Notification settings.

- User-specific configurations.

- Application-specific metadata.

 

Instead of continuously adding columns to the Customers table, developers may introduce a JSON column.

 

Customers table

customer_id

name 

profile_config

101

John

JSON document

102

Sarah

JSON document

 

The profile_config column might contain:

 

{ "preferences": { "emailNotifications": true, "smsNotifications": false }, "address": { "city": "Bangalore", "country": "India" }, "settings": { "theme": "dark", "language": "en" } }

   

This provides flexibility because new attributes can be introduced without modifying the relational schema. For example, adding a new preference such as pushNotifications does not require an ALTER TABLE statement.

 

But is this always a good design?

Not necessarily. While JSON columns solve some schema flexibility problems, they can introduce other challenges.

 

a. Data Integrity

Traditional relational columns can enforce data types, NOT NULL constraints, foreign keys, and other constraints directly.

 

With JSON, maintaining consistent structures and validating nested attributes may require additional database constraints or application-level validation.

 

b. Query Complexity

Suppose the application needs to retrieve all customers who have enabled email notifications. The database must extract and evaluate a value inside the JSON document.

 

For example, PostgreSQL supports JSONB queries:

 

SELECT customer_id, name FROM Customers WHERE profile_config -> 'preferences' ->> 'emailNotifications' = 'true';

   

This is supported functionality, but frequent queries against nested attributes may require carefully designed indexes.

 

c. Indexing and Performance

Relational columns can be indexed directly. JSON fields can also be indexed, but the appropriate indexing strategy depends on the database engine and query patterns.

 

d. Data Duplication and Relationships

If JSON documents start containing large amounts of information that already exists in other relational tables, the application may introduce duplication and make updates more complicated.

 

When does this become a problem?

When a significant portion of the application's core data is stored as JSON/XML, and developers frequently need to query, filter, join, validate, and update nested structures.

 

At that point, it is worth evaluating whether a document-oriented database would represent the data more naturally.

 

However, JSON support in relational databases is powerful. Storing JSON does not automatically mean the application needs a NoSQL database.

 

The decision should depend on how the data is accessed and maintained, not simply on the format in which it is stored.

 

2.5 Write Bottlenecks and Data Volume Challenges

As applications grow, database limitations may become visible not because of the data structure, but because of the volume and rate at which data is generated.

 

Consider a large e-commerce platform processing:

- Thousands of orders per second.

- Millions of inventory updates.

- Continuous user activity events.

- Payment transactions.

- Product view and click events.

 

Initially, a single relational database server may handle these workloads comfortably. But as traffic increases, the database may start experiencing resource contention and throughput limitations.

 

There are two important scenarios to understand.

 

a. Write Bottlenecks

A write bottleneck occurs when the database cannot process incoming write operations at the required rate.

 

For example, imagine an application receiving 50,000 write requests per second while the database can sustainably handle only 20,000 writes per second under the existing workload and configuration.

 

Several factors can contribute to write bottlenecks:

- Lock contention when multiple transactions update the same records.

- Index maintenance overhead during frequent inserts and updates.

- Transaction log and disk I/O limitations.

- Resource contention between concurrent transactions.

- Connection pool saturation.

- Hot partitions or heavily accessed records.

 

Adding more CPU or memory to the database server (vertical scaling) may improve performance, but it does not always solve the underlying bottleneck.

 

b. Data Volume and Horizontal Scalability

Another challenge occurs when the dataset becomes too large or the workload becomes too demanding for a single database server.

 

For example, consider an application storing several terabytes of transactional data and continuously receiving new records.

 

As the dataset grows:

- Indexes become larger.

- Backup and recovery operations take longer.

- Maintenance becomes more expensive.

- Queries may require more resources.

- Storage and I/O capacity become increasingly important.

 

One approach is to scale vertically by increasing server resources. Another approach is horizontal scaling. Horizontal scaling distributes data and workloads across multiple servers.

 

For example, instead of maintaining all customer records on one database server, the application can distribute customers across multiple database shards.

- Shard 1: Customers with IDs 1–1 million.

- Shard 2: Customers with IDs 1 million–2 million.

- Shard 3: Customers with IDs 2 million–3 million.

 

These are illustrative ranges; an actual sharding strategy must use non-overlapping partitions. This approach can distribute storage and write workloads across multiple machines.

 

However, sharding introduces additional architectural complexity:

- Choosing an appropriate partition key.

- Managing data distribution.

- Handling cross-shard queries.

- Maintaining consistency across distributed transactions.

- Rebalancing data as workloads change.

- Managing failures and replication.

 

It is important to understand that relational databases can also support horizontal scaling through sharding, partitioning, replication, and distributed SQL architectures.

 

The challenge is not that relational databases cannot scale horizontally. It is that distributing relational workloads while preserving transaction guarantees and query flexibility can become increasingly complex.

 

This is where distributed database technologies such as Apache Cassandra, Amazon DynamoDB and ScyllaDB become attractive for specific workloads.

 

They are designed around distributed data storage and access patterns, making them suitable for applications requiring high throughput, large-scale data distribution, and horizontal scalability.

 

When does this become a problem?

When the application consistently exceeds the sustainable capacity of its current database architecture, and the cost or complexity of scaling the existing system becomes unacceptable.

 

Before switching databases, however, investigate query optimization, indexing, caching, connection management, replication, and workload separation. A poorly optimized database may appear to have a scalability problem when the actual issue is its implementation.

 

2.6 Transactional Workloads Competing with Analytical Workloads

Another common challenge in enterprise applications is the coexistence of transactional and analytical workloads on the same database infrastructure.

 

These two types of workloads have fundamentally different requirements.

 

Let's understand this using an e-commerce application. During the day, the application continuously processes customer orders, payment transactions, inventory updates, and shipping information.

 

At the same time, business teams need reports answering questions such as:

- What were the top-selling products this month?

- Which regions generated the highest revenue?

- What is the average order value?

- How has customer purchasing behavior changed over the last year?

- Which products have declining sales?

 

Both types of workloads need access to the same business data, but their execution patterns are very different.

 

a. OLTP: Online Transaction Processing

OLTP systems are designed to handle day-to-day business transactions.

 

Typical characteristics:

- Frequent INSERT, UPDATE, and DELETE operations.

- Short-running queries.

- High concurrency.

- Small amounts of data accessed per transaction.

- Strong transactional guarantees.

 

Examples include:

- Creating an order.

- Processing a payment.

- Updating inventory.

- Changing customer information.

 

b. OLAP: Online Analytical Processing

OLAP systems are designed to analyze large volumes of historical data.

 

Typical characteristics:

- Complex queries involving multiple tables.

- Large aggregations and scans.

- GROUP BY and analytical functions.

- Queries processing millions or billions of records.

- Longer-running analytical operations.

 

Examples include:

- Monthly sales analysis.

- Customer segmentation.

- Revenue forecasting.

- Product performance reports.

- Business intelligence dashboards.

 

What happens when both workloads share the same database?

Imagine a business analyst running a query to calculate total sales across several years of historical orders.

 

SELECT product_id, SUM(quantity * unit_price) AS total_sales FROM Order_Items WHERE order_date >= '2023-01-01' GROUP BY product_id ORDER BY total_sales DESC;

This query might need to scan millions of records, perform aggregations, and consume substantial CPU, memory, and disk I/O. Meanwhile, customers are continuing to place orders and update their shopping carts.

 

The analytical query may compete with transactional operations for:

- CPU resources.

- Memory.

- Disk I/O bandwidth.

- Database connections.

- Cache resources.

 

Depending on the database engine and execution plan, long-running queries can also contribute to lock contention or other forms of resource contention.

 

As a result, an analytical workload can negatively affect the response times of customer-facing transactional operations.

 

How do modern architectures solve this?

One common approach is to separate transactional and analytical workloads. A typical architecture looks like this:

 

The OLTP database handles application transactions.

Changes are captured through Change Data Capture (CDC), replication, or ETL pipelines.

The data is moved into an analytical storage system.

Analytical queries run against the analytical system rather than the production transactional database.

 

For example:

Workload

Possible Technology

Transaction processing 

PostgreSQL, MySQL, SQL Server

 

Data ingestion and streaming 

Kafka

Batch processing 

Apache Spark

Analytical storage 

BigQuery, Snowflake, Redshift

Dashboards and reporting 

Tableau, Superset

 

 

This architecture allows each system to be optimized for its intended workload. For example, a company may use PostgreSQL for order processing while using BigQuery for large-scale reporting and analytics.

 

This is an important architectural distinction, the solution to an analytical performance problem is not necessarily replacing the transactional relational database with NoSQL. Often, the better solution is to introduce a dedicated analytical platform.

 

When does this become a problem?

When reporting, aggregations, and large-scale analytical queries begin affecting the performance and availability of business-critical transactional operations.

 

At that point, separating OLTP and OLAP workloads becomes an important architectural consideration.

 

Summary: Recognizing the Warning Signs

Let's consolidate the situations we discussed and understand which alternative database models might be worth evaluating.

 

Warning sign 

Underlying challenge 

Technology to evaluate

Sparse tables

Too many optional attributes 

Document DB

 

Frequently changing schemas

Rigid data structures

Document DB

 

 

 

 

Extensive EAV patterns 

Complex attribute queries

Document DB

 

Deep relationship traversal

Complex recursive joins

Graph DB

 

Large JSON/XML structures

Nested data management 

Document DB

 

High write throughput

Distributed write scalability

Wide-Column / Distributed KV

 

Massive data volume

Distributed storage

Distributed databases

 

Analytics affecting transactions 

Competing workloads

Data warehouse / OLAP

 

 

These are starting points for architectural evaluation, not automatic migration rules. A relational database can address many of these challenges through appropriate modeling, indexing, partitioning, replication, JSON support, and workload separation.

 

Relational databases do not suddenly become unsuitable when an application grows. In fact, many large-scale applications continue using relational databases successfully for decades.

 

The warning signs appear when the application's requirements start conflicting with the assumptions or operational characteristics of its existing data model.

 

Some important observations:

-       Data structure matters: If your data is highly dynamic, or sparse, a document-oriented model might provide a more natural representation.

-       Access patterns matter: If your primary operations involve traversing complex relationships, graph databases may be more appropriate.

-       Workload matters: High-throughput distributed writes may benefit from wide-column or distributed key-value databases.

-       Scale matters: Large datasets may require partitioning, sharding, or distributed storage architectures.

-       Workload separation matters: Transactional and analytical operations often benefit from separate infrastructure.

 

The most important lesson is that database selection should be driven by application requirements rather than technology trends.

 

3. Understanding Different Database Models

In the previous sections, we explored why relational databases became the foundation of enterprise applications and identified situations where the traditional data model may not be the most suitable choice for certain scenarios.

 

As applications evolve, different types of data and workloads introduce different requirements.

 

For example:

-       An application managing user sessions needs extremely fast key-based lookups.

-       An e-commerce platform managing product catalogs may need flexible data structures.

-       An IoT platform collecting millions of sensor readings needs efficient time-based storage and retrieval.

-       A social networking application needs to traverse complex relationships between users.

-       A large-scale distributed application needs to store and retrieve data across multiple servers and geographical regions.

 

Trying to solve all these problems using the same database model may introduce unnecessary complexity.

 

This is why several database models have evolved, each designed around particular data structures, access patterns, and scalability requirements.

 

Before exploring individual technologies, let's understand the major database categories and how they differ.

 

3.1 Overview of Different Database Models

Database systems can be classified based on how they organize, store, and retrieve information. The following are some of the most commonly used database models.

 

-       Key-Value databases

-       Document databases

-       Column Oriented Databases

-       Wide-Column databases

-       Graph databases

-       Time-Series databases

-       Distributed databases

 

One important distinction: these categories are not mutually exclusive. For example, a key-value database can also be distributed, and a wide-column database is commonly distributed. A database may also support multiple data models.

 

3.2 Key-Value Databases: Simple and Fast Data Access

A key-value database is one of the simplest database models.

 

It stores information as a collection of key-value pairs, similar to how a HashMap or dictionary works in programming languages such as Java, Python, and JavaScript.

 

Each record consists of:

- Key: A unique identifier used to locate the data.

- Value: The actual data associated with that key.

 

Think about a Java HashMap:

 

Map<String, String> userSessions = new HashMap<>(); userSessions.put("user101", "session-abc123"); userSessions.put("user102", "session-xyz456"); String session = userSessions.get("user101");

The key identifies the value, and the application retrieves it directly without searching through every entry.

 

A key-value database follows a similar concept, but stores data persistently and can support distributed storage, replication, expiration, and other database capabilities.

 

How does it work?

Consider an e-commerce application that needs to maintain user sessions.

 

Instead of querying a relational database every time a user makes a request, the application can store the session information in a key-value database.

 

Example: User session storage

Key

Value

user:101 

session-abc123

user:102 

session-xyz456

user:103 

session-pqr789

 

The application does not need to understand the internal structure of the stored value to retrieve it using its key.

 

For example, using Redis:

 

SET user:101 session-abc123 GET user:101

 

Redis also supports richer data structures, including hashes, lists, sets, sorted sets, and streams. So it is more capable than a simple string-to-string key-value store.

 

Popular key-value databases

-       Redis: In-memory data structures and low-latency access.

-       Amazon DynamoDB: Managed distributed NoSQL database.

-       Aerospike: Distributed database designed for high-throughput, low-latency workloads.

 

Where are key-value databases used?

Use case

Example

Caching

Store frequently accessed product details

Session management 

Maintain logged-in user sessions

 

Shopping carts 

Retrieve a cart using customer ID

 

User preferences 

Store user-specific settings

 

Rate limiting

Track API requests per user

Feature flags

Retrieve application configuration

 

Advantages

- Very fast key-based retrieval.

- Simple data model.

- Easy to distribute and partition by key.

- Often supports expiration (TTL).

- Suitable for high-throughput workloads.

 

Limitations

- Access is often optimized around known keys.

- Complex filtering and joins are generally not its strength.

- Applications may need to maintain additional indexes or lookup structures for non-key queries.

- Data modeling becomes important when access patterns change.

 

When should you consider it?

When the application primarily needs to retrieve or update data using a known identifier, and low latency is more important than complex querying.

 

3.3 Document Databases: Working with Flexible Data Structures

Document databases store information as self-contained documents rather than traditional rows and columns. These documents are commonly represented using JSON or BSON (Binary JSON).

 

Unlike relational databases, where a table generally has a predefined set of columns, documents within the same collection can have different structures.

 

Consider an e-commerce application managing products.

 

A relational database might require several tables to represent different product types and their attributes. A document database can represent each product as an independent document.

 

Example: Laptop document

 

{ "_id": 101, "name": "Laptop", "category": "Electronics", "price": 75000, "attributes": { "processor": "Intel i7", "ram": "16GB", "storage": "512GB" } }

Example: Mobile phone document

{ "_id": 102, "name": "Mobile", "category": "Electronics", "price": 25000, "attributes": { "battery": "5000mAh", "camera": "50MP", "screen": "6.5 inches" } }

   

Notice that the two documents have different attributes.

 

There is no requirement to add processor, RAM, battery, and camera columns to a common collection just to accommodate different product types.

 

How does it work?

Document databases organize documents into collections. A collection is broadly comparable to a table in a relational database, while an individual document is comparable to a row.

 

However, the important difference is that documents can contain nested objects, arrays, and different fields.

 

For example, in MongoDB:

 

db.products.insertOne({ name: "Laptop", category: "Electronics", price: 75000, attributes: { processor: "Intel i7", ram: "16GB" } });

To retrieve products based on a nested attribute:

 

db.products.find({ "attributes.ram": "16GB" });

Document databases also support indexing, aggregation pipelines, filtering, and other querying capabilities.

 

Popular document databases

-       MongoDB – Widely used document-oriented database.

-       Couchbase – Distributed document database with key-value capabilities.

 

Where are document databases used?

Use case

Example

Product catalogs 

Different product categories with different attributes

 

 

Content management

Articles with flexible metadata

 

User profiles

User-specific configuration and preferences

Configuration management 

Application settings stored as documents

 

Content platforms

Nested content and metadata

 

Advantages

- Flexible schema.

- Natural representation of nested data.

- Related information can often be retrieved in one operation.

- Supports indexes on document fields.

- Suitable for applications with evolving data structures.

 

Limitations

- Data duplication can occur when information is embedded in multiple documents.

- Cross-document transactions and joins may have different capabilities and costs depending on the database.

- Maintaining consistency across duplicated data requires careful design.

- Poor document design can result in large documents and inefficient updates.

 

When should you consider it?

When the application manages semi-structured data, where entities have different attributes and related information is commonly accessed together.

 

An important architectural consideration is deciding what to embed inside a document and what to reference separately. This decision directly influences performance, consistency, and document size.

 

3.4 Understanding Row-Oriented, Column-Oriented, and Wide-Column Databases

This is one of the most important areas to understand because the terminology can be confusing.

 

The terms column-oriented and wide-column sound similar, but they describe different storage and data models.

 

Before understanding wide-column databases, let's first understand how traditional relational databases physically organize data.

 

a. Row-Oriented Databases

Traditional relational databases such as PostgreSQL, MySQL, and SQL Server typically use row-oriented storage for their regular tables.

 

Consider an Employees table:

employee_id

name

department 

salary

101

John 

Engineering

120000

102

Sarah

Finance

90000

103

David

Engineering

110000

 

In a row-oriented database, values belonging to the same record are stored together.

 

If an application needs to retrieve the complete details of one employee, the database can efficiently retrieve that employee's row.

 

For example:

SELECT * FROM Employees WHERE employee_id = 101;

   

This is a natural fit for transactional workloads.

 

Where does row-oriented storage work well?

- Banking transactions.

- Order processing.

- Employee management.

- Inventory updates.

- Applications that frequently retrieve or modify complete records.

 

The main advantage is that all the fields belonging to a record are stored together, making complete-record access efficient.

 

However, consider a different requirement: "Calculate the average salary of all employees in the company."

 

The database only needs the Salary column, but in a row-oriented layout, records are organized with all their other fields as well.

 

Depending on the database engine, indexes, caching, and execution plan, this can result in reading more data than necessary. This is where column-oriented storage becomes useful.

 

b. Column-Oriented Databases

Column-oriented databases store data by columns rather than grouping all attributes of a record together.

 

Using the same Employees table, the conceptual storage becomes:

 

      

Now consider the same analytical query:

SELECT AVG(salary) FROM Employees;

The database primarily needs to read the Salary column rather than all the other attributes. This can significantly reduce the amount of data scanned for analytical queries, especially when tables contain many columns but queries access only a few of them.

 

Columnar systems also benefit from:

-       Better compression because similar data types and values are stored together.

-       Efficient vectorized processing.

-       Faster large-scale aggregations.

-       Reduced I/O for queries that access only a subset of columns.

 

Popular column-oriented analytical databases

-       Google BigQuery – Cloud data warehouse.

-       Amazon Redshift – Cloud data warehouse.

-       ClickHouse – Column-oriented analytical database.

-       Snowflake – Cloud data platform using columnar storage.

 

Where are column-oriented databases used?

-       Business intelligence dashboards.

-       Data warehousing.

-       Large-scale aggregations.

-       Historical reporting.

-       Analytical workloads involving billions of records.

 

For example, consider a retail company analyzing five years of sales data containing hundreds of millions of records.

 

An analytical query might calculate revenue by product category, region, and month.

 

A columnar database can read the relevant columns and process them efficiently without necessarily reading every attribute of every record.

 

Important: Column-oriented databases are not inherently better than row-oriented databases. They are optimized for different workloads. Frequent updates to individual records, transactional constraints, and point lookups may favor row-oriented systems.

 

C. Wide-Column Databases

Now let's understand wide-column databases.

 

Despite the similar name, wide-column databases are not simply column-oriented analytical databases.

 

They use a different data model called the wide-column or column-family model.

 

This model is designed to handle large, distributed, sparse datasets where different rows can contain different sets of columns.

 

Consider an IoT application collecting sensor information from thousands of devices.

 

One device might report:

- Temperature

- Humidity

- Pressure

 

Another device might report:

- Temperature

- Humidity

- Battery Level

- Signal Strength

 

A traditional relational model might require a common schema with many optional columns, or additional tables to handle different sensor attributes.

 

A wide-column database provides more flexibility. Conceptually, a wide-column table might look like this:

The important point is that wide-column databases can support rows with different sets of columns. They are designed to manage sparse data efficiently.

 

How does a wide-column database organize data?

Let's take Apache Cassandra as an example. Cassandra organizes data using keyspaces, tables, partition keys, clustering columns, and regular columns.

 

A simplified example:

CREATE TABLE sensor_readings ( device_id TEXT, reading_time TIMESTAMP, temperature DOUBLE, humidity DOUBLE, PRIMARY KEY (device_id, reading_time) );

   

Here:

-       device_id is the partition key.

-       reading_time is a clustering column.

-       temperature and humidity are regular columns.

 

The partition key determines which partition stores the data, while clustering columns help organize records within that partition.

 

This design allows an application to efficiently retrieve sensor readings for a particular device over a time range.

 

For example:

 

SELECT * FROM sensor_readings WHERE device_id = 'Device-101' AND reading_time >= '2026-11-01' AND reading_time < '2026-11-24';

   

Cassandra is particularly effective when queries are designed around the partition key and clustering columns.

 

Unlike a traditional relational database, it does not encourage arbitrary joins or unrestricted ad hoc queries across the entire dataset.

 

Popular wide-column databases

-       Apache Cassandra – Distributed wide-column database.

-       Apache HBase – Distributed column-family database built on Hadoop's storage ecosystem.

-       Google Cloud Bigtable – Managed wide-column database service.

 

Where are wide-column databases used?

-       IoT sensor data.

-       Event ingestion.

-       Large-scale activity tracking.

-       Messaging and time-ordered records.

-       Distributed applications with predictable access patterns.

 

Advantages

-       Designed for horizontal scalability.

-       High write throughput for suitable workloads.

-       Efficient access using partition keys.

-       Handles sparse and large datasets.

-       Supports distributed replication.

 

Limitations

-       Data modeling is heavily driven by query patterns.

-       Joins are generally not supported as in relational systems.

-       Poor partition-key selection can create hot partitions.

-       Cross-partition queries can be expensive.

-       Strong transactional capabilities may be more limited than in traditional relational databases, depending on the system.

 

D. Row-Oriented vs Column-Oriented vs Wide-Column: The Difference

Let's put all three concepts together.

      

 

Aspect

Row-Oriented

Column-oriented

Wide-column

Storage organization 

Records together 

Column values together 

Partitioned rows and column families

Primary strength 

Transactions 

Analytics

Distributed workloads

Schema 

Defined columns

Defined columns

Flexible/sparse columns, depending on model

Typical queries

Individual records 

Aggregations and scans 

Partition-key-based access

Examples 

PostgreSQL, MySQL

BigQuery, ClickHouse 

Cassandra, HBase

 

An important distinction to remember:

-       Row-oriented and column-oriented describe how data is physically organized for storage and processing.

-       Wide-column describes a logical data model and storage architecture based on partitioned rows and column families.

 

Wide-column databases should not be confused with columnar analytical databases. Cassandra and Bigtable are not simply column-oriented versions of PostgreSQL.

 

3.5 Graph Databases: When Relationships Matter More Than Records

Relational databases represent relationships using foreign keys and JOIN operations. This works extremely well when relationships are relatively predictable.

 

But consider applications where the relationships themselves are the primary focus.

 

Examples include:

-       Social networking applications.

-       Fraud detection systems.

-       Recommendation engines.

-       Knowledge graphs.

-       Network topology analysis.

 

Imagine a social networking platform. A user can have hundreds or thousands of friends. Those friends can have their own connections, and connections can extend across multiple levels.

 

Consider the question: "Find friends of friends who are not already connected to me."

 

In a relational database, this may require multiple self-joins or recursive queries. As the relationship depth becomes unpredictable, the query can become increasingly complicated.

 

Graph databases solve this problem by representing data using nodes and edges.

 

How does a graph database work?

A graph consists of three fundamental concepts:

-       Nodes: Represent entities such as users, products, or organizations.

-       Edges: Represent relationships between entities.

-       Properties: Store attributes of nodes and relationships.

 

Imagine the following relationships:

-       Alice is friends with Bob.

-       Bob is friends with Charlie.

-       Charlie is friends with David.

 

These can be represented as connected nodes. Instead of joining multiple tables, the database traverses the relationships directly.

 

Using Neo4j, we can represent this using Cypher:

CREATE (alice:Person {name: 'Alice'}), (bob:Person {name: 'Bob'}), (charlie:Person {name: 'Charlie'}), (alice)-[:FRIEND_OF]->(bob), (bob)-[:FRIEND_OF]->(charlie);

To find friends of friends:

 

MATCH (alice:Person {name: 'Alice'}) -[:FRIEND_OF*2] ->(friend) RETURN friend;

   

The *2 indicates traversal across two relationships. This makes relationship-centric queries much more natural.

 

Popular graph databases

-       Neo4j – Popular native graph database.

-       Amazon Neptune – Managed graph database service.

-       ArangoDB – Multi-model database supporting graph, document, and key-value models.

 

Where are graph databases used?

Use case 

Example

Social networks

Friend recommendations

Fraud detection

Detect suspicious transaction relationships

Recommendation engines 

Discover related products

Knowledge graphs 

Connect people, organizations, and concepts

Network management 

Analyze connected infrastructure

 

 

Advantages

-       Natural representation of interconnected data.

-       Efficient relationship traversal.

-       Supports variable-depth relationships.

-       Useful for discovering indirect connections.

 

Limitations

-       Not necessarily suitable for every transactional workload.

-       Large graph traversals can still be expensive.

-       Distributed graph processing introduces complexity.

-       Requires a different data modeling and querying mindset.

 

When should you consider it?

When the application's primary queries involve discovering and traversing relationships rather than retrieving individual records.

 

3.6 Time-Series Databases: Optimized for Time-Based Data

Many modern applications continuously generate data over time.

 

Examples include:

-       Application monitoring metrics.

-       CPU and memory utilization.

-       IoT sensor readings.

-       Stock market prices.

-       Website traffic.

-       System logs and telemetry.

 

This type of data has an important characteristic: every measurement is associated with a timestamp. Consider an application monitoring system collecting CPU utilization from servers every few seconds.

 

A typical record might look like this:

Timestamp

Server 

CPU Usage

10:00:00 

Server-101 

45%

10:00:05 

Server-101 

48%

10:00:10 

Server-101 

52%

10:00:15 

Server-101 

43%

 

As the number of monitored servers increases, the volume of time-based records can grow extremely quickly.

 

A traditional relational database can store this data, but specialized time-series databases provide features optimized for these workloads.

 

How does a time-series database work?

Time-series databases organize measurements around timestamps. The database can efficiently retrieve measurements for a particular time range.

 

Consider a query: "Show average CPU utilization for server-101 over the last 24 hours."

 

This type of query is common in time-series workloads.

 

Time-series databases often provide specialized features:

-       Time-based partitioning: Organize data into time windows for efficient retrieval and management.

-       Retention policies: Automatically remove older data after a defined period.

-       Downsampling: Convert high-frequency measurements into aggregated values.

-       Compression: Efficiently store repetitive time-based measurements.

-       Time-window aggregations: Calculate averages, minimums, maximums, and other statistics over specific intervals.

 

For example, instead of retaining every CPU measurement forever, a monitoring platform might keep raw measurements for seven days, five-minute aggregates for three months, and hourly aggregates for a year.

 

This reduces storage costs while preserving historical trends.

 

Popular time-series databases

-       InfluxDB: Specialized time-series database.

-       TimescaleDB: PostgreSQL-based time-series database extension.

-       Prometheus: Monitoring and time-series metrics system.

-       VictoriaMetrics: Time-series monitoring and storage platform.

 

Where are time-series databases used?

Use case

Example

Infrastructure monitoring

CPU and memory utilization

 

IoT

Temperature and sensor readings

Financial markets

Stock prices and trading metrics

Application monitoring 

Request latency and throughput

Industrial systems 

Machine performance measurements

 

Advantages

-       Optimized for timestamp-based queries.

-       Efficient retention and data lifecycle management.

-       Compression for repetitive time-series data.

-       Efficient time-window aggregations.

 

Limitations

-       Not designed to replace every transactional database.

-       Complex relationships between entities may require another data model.

-       High-cardinality dimensions can introduce performance and storage challenges.

-       Data ingestion and query capabilities vary across products.

 

When should you consider it?

When your application continuously generates timestamped measurements and frequently queries, aggregates, or analyzes them over time.

 

3.7 Distributed Databases: Storing and Processing Data Across Multiple Machines

So far, we have explored databases based on how they represent data. Now let's look at another important concept: distributed databases.

 

A distributed database is a database system in which data is stored across multiple machines or nodes that work together to provide a unified database service.

 

Instead of relying entirely on a single server, a distributed database can distribute data and workloads across multiple nodes.

 

Why is this necessary?

Consider a global e-commerce application serving millions of customers across different regions.

 

A single database server may eventually become a bottleneck in terms of:

-       Storage capacity

-       Read and write throughput

-       Network bandwidth

-       Availability

-       Geographic latency

 

A distributed architecture allows the system to distribute data and processing across multiple machines.

 

How does a distributed database work?

There are three important concepts to understand.

 

a. Sharding: Distributing Data Across Nodes

Sharding divides a dataset into smaller partitions and distributes them across different servers. For example, a customer database may be distributed based on customer ID.

 

- Node 1 stores customers 1–1 million.

- Node 2 stores customers 1 million –2 million.

- Node 3 stores customers 2 million –3 million.

 

The actual ranges must be non-overlapping, this is only an illustration of partitioning. When a request arrives, the database or application determines which node contains the required data.

 

The main advantage is that storage and workloads can be distributed across multiple machines.

 

b. Replication: Maintaining Multiple Copies of Data

Replication means maintaining copies of data across multiple nodes.

 

For example:

- Node 1: Primary replica.

- Node 2: Secondary replica.

- Node 3: Secondary replica.

 

If one node fails, another replica may continue serving requests, depending on the database's replication and failover configuration. Replication improves availability and can also distribute read traffic.

 

However, replicas introduce consistency considerations. Depending on the system, replication may be synchronous or asynchronous.

 

c. Partitioning and Fault Tolerance

Distributed databases are designed to handle data distribution and node failures. If one machine becomes unavailable, the system may continue operating using other replicas or partitions.

 

However, the actual guarantees depend on the database architecture and configuration.

 

For example, some databases prioritize consistency, while others prioritize availability and eventual convergence for particular operations.

 

Popular distributed databases

-       Apache Cassandra: Distributed wide-column database.

-       Amazon DynamoDB: Managed distributed NoSQL database.

-       CockroachDB: Distributed SQL database.

-       YugabyteDB: Distributed SQL database.

-       Google Cloud Spanner: Globally distributed relational database service.

 

An important observation: distributed databases are not necessarily NoSQL databases.

 

For example, CockroachDB, YugabyteDB, and Google Cloud Spanner provide SQL and relational data capabilities while distributing data across multiple nodes.

 

This distinction is important because distribution describes the deployment and data architecture, whereas relational, document, key-value, and wide-column describe data models.

 

Advantages

-       Horizontal scalability.

-       High availability through replication.

-       Fault tolerance.

-       Ability to distribute workloads geographically.

-       Large-scale data storage.

 

Limitations

-       Distributed transactions can be more complicated.

-       Network latency affects operations.

-       Replication introduces consistency trade-offs.

-       Operational complexity increases.

-       Cross-partition queries may be expensive.

 

When should you consider it?

When the application requires more storage, throughput, availability, or geographic distribution than a single database server can reasonably provide.

 

3.8 Comparing All Database Models

Let's bring everything together. The following table summarizes the key characteristics of the database models we explored.

 

   

3.9 One Application Can Use Multiple Database Models

Here is one final concept worth understanding before moving to the next section. Choosing a database does not mean selecting one technology for the entire application.

 

Large-scale enterprise applications frequently use multiple database technologies, each serving a specific purpose. This architectural approach is called Polyglot Persistence.

 

Consider an e-commerce platform. A possible architecture could look like this:

 

Application requirement

Database choice

Reason

Customer and order transactions

PostgreSQL

ACID transactions and relational integrity

Shopping cart and sessions 

Redis

Low-latency key-based access

Product catalog

MongoDB

Flexible product attributes

Product recommendations

Neo4j

Relationship traversal

Application monitoring 

InfluxDB 

Time-series metrics

Business analytics 

BigQuery 

Large-scale analytical queries

 

Each database is selected based on the problem it solves best.

 

-       This provides flexibility, but it also introduces additional complexity:

-       Multiple database technologies to operate.

-       Different backup and recovery strategies.

-       Data synchronization between systems.

-       Multiple consistency models.

-       More monitoring and observability requirements.

-       Additional infrastructure and operational costs.

 

Therefore, using multiple databases should be an intentional architectural decision, not a goal in itself.

 

Key Takeaways

The database ecosystem has evolved beyond the traditional relational model because different applications have different data structures, access patterns, and scalability requirements.

 

The most important concepts to remember are:

-       Key-Value: Best suited for simple, fast lookups using known keys.

-       Document: Suitable for flexible and nested data structures.

-       Column-Oriented: Optimized for analytical queries that process selected columns across large datasets.

-       Wide-Column: Designed for distributed storage of large, sparse datasets with predictable access patterns.

-       Graph: Useful when relationships and traversals are central to the application.

-       Time-Series: Optimized for timestamped measurements and time-based queries.

-       Distributed: Distributes data and workloads across multiple machines to achieve scalability and availability.

 

One particularly important distinction is that a database's data model and its storage architecture are not the same thing. A database can be relational and distributed, or NoSQL and distributed. Similarly, column-oriented and wide-column databases solve different problems despite their similar names.

 

The goal is not to replace relational databases with newer technologies. It is to understand the strengths and limitations of each model and choose the one that aligns with the application's requirements.

 

4. Distributed Data Processing: Beyond Database Storage

So far, we have explored different database models and how they address different data storage requirements. However, choosing the right database is only one part of designing a data architecture.

 

As applications grow, another challenge emerges: How do we process and analyze large volumes of data efficiently?

 

Consider an e-commerce platform that processes millions of orders every day. Its operational database stores customer details, products, orders, and payments. But the business may also want to answer questions such as:

 

-       What is the total revenue generated across all regions over the last 12 months?

-       Which products are frequently purchased together?

-       How does customer purchasing behavior change over time?

-       Which products are likely to experience increased demand next month?

-       What percentage of orders are delayed in each delivery region?

 

These questions require processing large amounts of historical data, performing aggregations, joining datasets, and identifying patterns.

 

Running such workloads directly against the operational database can affect the performance of applications that depend on it.

 

This introduces an important architectural distinction: A database is primarily responsible for storing and retrieving data, while a data processing engine is responsible for transforming, aggregating, and analyzing data at scale.

 

Let's understand how distributed data processing addresses this problem.

 

4.1 Storage and Processing Are Different Problems

Imagine an e-commerce application with the following operational database:


The application frequently performs operations such as:

-       Creating a new order.

-       Updating payment status.

-       Retrieving customer order history.

-       Updating delivery information.

 

These are transactional operations. They typically access a relatively small number of records and need predictable response times.

 

Now imagine the business wants to calculate the total revenue generated by every region across 500 million orders.

SELECT region, SUM(amount) AS total_revenue FROM orders GROUP BY region;

   

The query may need to scan hundreds of millions of records and perform large aggregations.

 

Although the database can execute this query, doing so repeatedly on the same system that serves customer-facing transactions can consume significant CPU, memory, disk I/O, and database connections.

 

The problem is not necessarily that the database cannot execute the query. The problem is that transaction processing and large-scale analytical processing have different resource and performance requirements.

 

A common architecture separates these workloads:

-       The operational database handles application transactions

-       Changes are captured and moved to an analytical environment

-       Distributed processing engines transform and aggregate the data

-       Processed data is stored in a data warehouse or analytical database

-       BI tools and analytical applications query the processed data

 

This separation allows each system to focus on the workload it handles best.

 

4.2 MapReduce: The Foundation of Distributed Data Processing

Before exploring modern distributed processing engines, let's understand one of the fundamental ideas behind large-scale data processing: MapReduce.

 

The basic idea is simple, instead of processing an enormous dataset on a single machine, divide the work into smaller tasks, execute them across multiple machines, and combine their results.

 

Consider the requirement to calculate total sales for each region. Suppose the input dataset contains millions of order records distributed across multiple machines.

 

Step 1: Map

The Map phase processes individual records and produces intermediate key-value pairs. For example, each order is converted into:

 

(Bangalore, 2500)

(Mumbai, 4000)

(Bangalore, 1500)

(Chennai, 3000)

(Mumbai, 2000)

 

Each mapper processes a subset of the input data independently.

 

Step 2: Shuffle and Sort

The framework groups intermediate values by their keys.

 

Bangalore -> [2500, 1500]

Mumbai    -> [4000, 2000]

Chennai   -> [3000]

 

This phase is called Shuffle and Sort. It distributes records with the same key to the same reducer.

 

Step 3: Reduce

The Reduce phase aggregates the grouped values.

 

Bangalore -> 4000

Mumbai    -> 6000

Chennai   -> 3000

 

The important point is that different machines can process different portions of the dataset in parallel. A simplified MapReduce example in Java-like pseudocode:

 

// Map phase map(order) { emit(order.region, order.amount); } // Reduce phase reduce(region, amounts) { total = sum(amounts); emit(region, total); }

   

The framework takes care of distributing the input, executing tasks, moving intermediate data, and handling failures.

 

Why is this important?

Without distributed processing, a single machine must read and process the entire dataset. With distributed processing, the work can be divided across multiple machines, allowing large datasets to be processed in parallel.

 

MapReduce introduced a powerful programming model for processing large datasets across clusters of commodity machines.

 

4.3 Apache Hadoop: Distributed Storage and Processing

Hadoop introduced an ecosystem for distributed storage and processing. Two important components are:

 

a. HDFS (Hadoop Distributed File System)

HDFS stores large files across multiple machines in a cluster.

 

For example, a 1 TB file can be divided into blocks and distributed across several machines. Blocks are typically replicated to provide fault tolerance.

 

If one machine fails, the system can retrieve the data from another replica.

 

b. MapReduce

Hadoop MapReduce processes data stored in HDFS by distributing computation across the cluster. Refer this post for more details.

 

When is Hadoop useful?

-       Processing large historical datasets.

-       Batch-oriented data processing.

-       Log analysis.

-       Large-scale ETL pipelines.

-       Distributed storage of files and structured or semi-structured data.

 

One limitation of traditional Hadoop MapReduce is that intermediate results are frequently written to disk between processing stages. For workloads involving multiple transformations, this can introduce significant overhead.

 

This led to the development and adoption of faster distributed processing engines such as Apache Spark.

 

4.4 Apache Spark: Faster Distributed Data Processing

Spark addresses several limitations of traditional MapReduce by supporting in-memory computation, optimized execution plans, and multiple processing APIs.

 

Consider a pipeline that performs the following operations:

-       Read 500 million order records.

-       Filter out cancelled orders.

-       Group orders by region.

-       Calculate total revenue.

-       Identify the top-performing regions.

 

In traditional MapReduce, intermediate processing stages often involve disk writes and reads. Spark can keep intermediate datasets in memory when appropriate, reducing repeated disk I/O and improving performance for many multi-stage workloads.

 

What happens behind the scenes?

-       Spark reads the data from distributed storage

-       It divides the data into partitions

-       Multiple executors process those partitions in parallel

-       The results are aggregated and returned

 

Spark uses lazy evaluation: transformations such as filter() and groupBy() build an execution plan. Actual execution generally starts when an action such as show() or write() is invoked.

 

The Catalyst optimizer in Spark SQL optimizes query plans before execution.

 

The key architectural lesson: Choosing a database determines how data is stored and accessed. Choosing a processing architecture determines how that data is transformed and analyzed at scale. Modern data platforms often need both.

 

5. How to Choose the Right Database for Your Application

By now, we have explored relational databases, NoSQL databases, graph databases, time-series databases, distributed databases, and distributed data processing technologies.

 

Each database model solves a particular set of problems. But an important question remains: How do we decide which database is the right choice for a particular application?

 

There is no universally best database. A database that works exceptionally well for an e-commerce application may not be suitable for a real-time fraud detection system or an IoT platform processing millions of sensor readings.

 

The right choice depends on the application's data, access patterns, consistency requirements, scale, operational constraints, and the team's ability to operate the technology.

 

Let's explore the key factors to consider before making a database decision.

 

5.1 Understand the Data Structure

The first question to ask is:

 

What kind of data does the application store, and how is that data related?

 

Different database models are designed around different ways of organizing information. Consider an e-commerce application.

 

It manages several types of information:

-       Customers and their profiles

-       Products and product categories

-       Orders and order items

-       Customer preferences

-       Product recommendations

-       Application events

 

Not all these entities have the same structure or relationships.

 

Relational data

Consider customers, orders, and payments. These entities have clearly defined structures and relationships.

 

For example:

CREATE TABLE Customers ( customer_id BIGINT PRIMARY KEY, name VARCHAR(100), email VARCHAR(150) ); CREATE TABLE Orders ( order_id BIGINT PRIMARY KEY, customer_id BIGINT, order_date TIMESTAMP, total_amount DECIMAL(12, 2), FOREIGN KEY (customer_id) REFERENCES Customers(customer_id) );

   

A relational database is a natural choice because:

-       The data has a well-defined schema

-       Relationships between entities are important

-       Referential integrity matters

-       Transactions must maintain consistency

 

PostgreSQL, MySQL, and SQL Server are suitable candidates.

 

Semi-structured data

Now consider product information. A laptop may have RAM, processor, and storage attributes, while a refrigerator may have capacity, energy rating, and cooling technology.

 

Maintaining every possible product attribute in one fixed table may become difficult.

 

A document database can represent these products naturally:

 

{ "productId": "P1001", "name": "Laptop", "category": "Electronics", "attributes": { "processor": "Intel i7", "ram": "16GB", "storage": "1TB SSD" } }

A document database such as MongoDB can be a good fit when product structures vary significantly and are commonly retrieved as complete documents.

 

Highly interconnected data

Now imagine a recommendation engine that needs to identify:

-       Customers who purchased similar products

-       Products frequently purchased together

-       Friends of customers who purchased a particular product

-       Relationships between customers, products, brands, and categories

 

These are relationship-heavy queries. A graph database such as Neo4j can make traversing these relationships more natural.

 

Choosing based on data structure

Data characteristics 

Database model to evaluate

Structured data with strong relationships

Relational

 

Flexible, nested documents 

Document

 

Simple key-based lookups 

Key-value

Large-scale partitioned records

Wide-column

 

Highly interconnected entities

Graph

Timestamped measurements 

Time-series

 

Large-scale analytical scans 

Columnar analytical database

 

 

 The important point is that the database should reflect the natural structure and relationships of the data.

 

However, do not choose a database only because the data looks like JSON, a graph, or a time series. Also consider how the application accesses that data.

 

5.2 Understand Read and Write Patterns

The second important consideration is how the application reads and writes data.

 

Two applications may store exactly the same type of information but require completely different database architectures because their access patterns differ.

 

Consider two systems.

 

Application A: E-commerce order management

- Creates orders

- Updates payment status

- Retrieves customer order history

- Updates inventory

- Performs transactional operations

 

Application B: IoT monitoring platform

- Receives millions of sensor readings

- Continuously inserts timestamped records

- Rarely updates existing measurements

- Queries data over time ranges

- Calculates averages and trends

 

Although both systems store structured information, their workloads are very different.

 

Common access patterns

Access pattern 

Example

Database to evaluate

Point lookup 

Retrieve user by ID

Key-value

Transactional reads/writes 

Create and update orders 

Relational

 

Complete document retrieval

Retrieve product catalog entry

Document

 

Time-range queries 

Sensor readings over 24 hours

Time-series

 

Relationship traversal 

Find connected customers

Graph

Large analytical scans 

Calculate yearly revenue 

Columnar OLAP

 

High-volume distributed writes 

Record application events

Wide-column or distributed database

 

 

Read-heavy workloads

Consider a product catalog where millions of customers browse products, but product information changes relatively infrequently.

 

The system may experience:

- High read traffic

- Relatively low write traffic

- Repeated retrieval of the same records

- Predictable query patterns

 

Potential approaches include:

- A document database for product records

- Read replicas for relational databases

- Redis for frequently accessed data

- Caching at the application or API layer

 

A database migration may not even be necessary. Sometimes caching and indexing solve the actual problem.

 

Write-heavy workloads

Now consider an IoT platform receiving millions of sensor readings every minute.

 

The workload involves:

- Continuous inserts

- High write throughput

- Timestamp-based access

- Retention and aggregation

- Data partitioning

 

A time-series database or distributed wide-column database may be worth evaluating.

 

A practical lesson

Before selecting a database, write down the application's most important queries and operations.

 

For example:

-       Get customer by customer ID.

-       Get all orders for a customer.

-       Update order payment status.

-       Get total revenue by region for the last 30 days.

-       Find products frequently purchased together.

 

These access patterns reveal more about database suitability than simply looking at the data model.

 

5.3 Evaluate Scalability Requirements

The third factor is scalability.

 

A database that performs well with 10,000 records may behave very differently when it needs to handle billions of records and thousands of concurrent requests.

 

But scalability is not just about the amount of stored data. It also depends on:

- Read throughput.

- Write throughput.

- Concurrent users.

- Query complexity.

- Data growth.

- Latency requirements.

- Geographic distribution.

 

Vertical scaling

Vertical scaling means increasing the resources of a database server.

 

For example:

- Increasing CPU cores.

- Increasing memory.

- Using faster storage.

- Increasing disk capacity.

 

This is often the simplest approach because the database remains on a single primary server.

 

However, it has limitations:

- Hardware capacity has practical limits.

- Larger machines can become expensive.

- A single primary can remain a bottleneck.

- Hardware maintenance and failures still need to be addressed.

 

Horizontal scaling

Horizontal scaling means distributing workloads or data across multiple machines.

 

There are two commonly used approaches.

 

a. Replication

Replication maintains copies of data across multiple database nodes.

 

For example:

- One primary handles writes.

- Multiple read replicas serve read queries.

 

This can increase read capacity and improve availability, depending on the replication architecture.

 

However, read replicas do not automatically increase write capacity. Replication lag may also mean that a replica returns slightly stale data.

 

b. Sharding

Sharding divides data across multiple database nodes. For example, customers can be distributed based on customer ID:

 

Shard 1: Customer IDs 1 - 1,000,000

Shard 2: Customer IDs 1,000,001 - 2,000,000

Shard 3: Customer IDs 2,000,001 - 3,000,000

 

Each shard manages only a portion of the overall dataset. This can increase storage and write capacity by distributing the workload.

 

However, sharding introduces challenges:

- Choosing a good partition key.

- Avoiding uneven data distribution.

- Handling cross-shard joins.

- Managing transactions across shards.

- Resharding when data grows.

 

Some distributed databases manage much of this complexity internally, while application-managed sharding requires more engineering effort.

 

Scalability comparison

Database model 

Common scaling approach

Relational

Vertical scaling, replication, partitioning, sharding, distributed SQL

Key-value

Partitioning and replication

Document

Sharding and replication

Wide-column

Distributed partitioning and replication

Graph

Often requires careful graph partitioning; some systems provide distributed capabilities

Time-series

Time-based partitioning and distributed storage

Columnar OLAP

Distributed storage and parallel query execution

 

Important: Relational databases are not inherently limited to vertical scaling. Modern distributed SQL systems such as CockroachDB, YugabyteDB, and Google Spanner support horizontal scaling while retaining SQL and relational data models.

 

The right approach depends on actual scale requirements, not assumptions about a particular database category.

 

5.4 Understand Consistency and Availability Requirements

The fourth consideration is how the application should behave when multiple users access or modify data simultaneously, or when parts of a distributed system fail.

 

Consider a banking application.

 

A customer transfers ₹10,000 from Account A to Account B.

 

The system must ensure:

- Account A is debited correctly.

- Account B is credited correctly.

- The transfer is not partially completed.

- Concurrent transactions do not corrupt account balances.

 

Strong transactional consistency is essential in this scenario.

 

Now consider a social media application. A user publishes a post, and the post appears in different feeds across the system. It may be acceptable if some users see the post a little later than others.

 

These applications have different consistency requirements.

 

Strong consistency

A read after a successful write returns the latest committed value according to the database's consistency guarantees.

 

This is important for:

- Banking transactions.

- Payment processing.

- Inventory reservation.

- Order management.

- Financial ledgers.

 

Relational databases commonly provide strong transactional guarantees through ACID transactions. Some distributed databases also provide strong consistency, depending on their configuration and architecture.

 

Eventual consistency

In an eventually consistent system, replicas may temporarily contain different values, but they are expected to converge if updates stop and the system continues operating normally.

 

For example:

A customer updates their profile picture. The updated picture may take a short time to appear across all application servers or geographic regions.

 

This may be acceptable for:

- Social media feeds.

- Product recommendations.

- Some caching systems.

- Certain user activity counters.

 

It is not necessarily acceptable for every operation in the same application. A shopping platform might tolerate delayed recommendation updates but require accurate inventory checks during checkout.

 

Understanding the CAP theorem

The CAP theorem is an important concept when designing distributed databases. It describes a trade-off that arises when a network partition occurs.

 

-       Consistency (C): Operations behave according to a single consistent view of the data.

-       Availability (A): Every request to a non-failing node receives a response, even if that response may not contain the latest data.

-       Partition Tolerance (P): The system continues operating despite communication failures between parts of the distributed system.

 

When a network partition occurs, a distributed system must trade off consistency against availability for the affected operations.

 

This does not mean that every database simply chooses two out of three in all situations. Partition tolerance is a practical requirement for distributed systems, and the important design decision is how the system behaves during a partition.

 

For example:

-       A CP-oriented approach may reject or delay certain operations rather than return potentially stale data.

-       An AP-oriented approach may continue serving requests while allowing temporary inconsistencies.

 

Different databases offer different consistency levels and configuration options. Therefore, understand the guarantees of the specific product rather than classifying an entire database category as either consistent or available.

 

Questions to ask

- Can the application tolerate stale reads?

- Must every successful write be immediately visible?

- What should happen if a network connection between regions fails?

- Can the application temporarily reject requests to preserve consistency?

- Are transactions required across multiple records or services?

 

These questions are especially important when choosing distributed databases.

 

5.5 Evaluate Query Complexity

Another important factor is the complexity of the queries the application needs to execute.

 

Consider an application that needs to perform the following operations:

-       Retrieve a customer and their orders.

-       Calculate total sales by region.

-       Find all connected users within three relationship levels.

-       Retrieve the last 24 hours of sensor readings.

-       Retrieve a product using its ID.

 

These operations represent very different query patterns. A relational database supports powerful joins, aggregations, filtering, and transactions.

 

For example: 

 

SELECT c.customer_id, c.name, SUM(o.total_amount) AS total_spent FROM Customers c JOIN Orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name;

   

This is a natural operation for a relational database. However, consider finding friends of friends, and then friends of those friends, across a large social network.

 

In SQL, recursive CTEs can solve this problem:

 

WITH UserConnections AS ( SELECT user_id, connected_user_id, 1 AS depth FROM Connections WHERE user_id = 100 UNION ALL SELECT c.user_id, c.connected_user_id, uc.depth + 1 FROM Connections c JOIN UserConnections uc ON c.user_id = uc.connected_user_id WHERE uc.depth < 3 ) SELECT * FROM UserConnections;

   

This works for bounded relationship traversal, but complex graph queries may become difficult to maintain and optimize using relational joins.

 

A graph database can express the same kind of traversal more naturally.

 

For example, using Cypher:

 

MATCH (user:User {id: 100})-[:CONNECTED_TO*1..3]->(friend) RETURN DISTINCT friend;

Similarly:

-       Time-range aggregations may fit time-series databases.

-       Large scans and aggregations may fit columnar analytical databases.

-       Simple ID-based lookups may fit key-value databases.

-       Flexible nested-object queries may fit document databases.

 

Query complexity decision matrix

Query requirement

Suitable database model

Multi-table joins and transactions 

Relational

 

Nested document retrieval

Document

 

Key-based lookup 

Key-value

Multi-level relationship traversal 

Graph

Time-window aggregation

Time-series

Large-scale analytical aggregation 

Columnar OLAP

 

High-volume partition-based access 

Wide-column

 

One important architectural principle is to evaluate the database against the actual query workload.

 

A database may support a particular query syntactically but may not execute it efficiently at the required scale.

 

5.6 Consider Operational Complexity and Cost

A database is not just a technology that developers interact with through SQL or APIs. It is also an infrastructure component that must be deployed, monitored, secured, backed up, upgraded, and maintained.

 

A technically suitable database may still be a poor choice if the organization cannot operate it reliably.

 

Consider two options.

 

Option A: PostgreSQL

- Mature ecosystem.

- Well-understood operational practices.

- Strong transactional capabilities.

- Managed hosting options.

- Familiar SQL interface.

 

Option B: A distributed database cluster

- Multiple nodes.

- Distributed replication.

- Partition management.

- Cluster monitoring.

- More complex failure scenarios.

- Potentially higher infrastructure and operational costs.

 

The second option may be justified when the workload requires its distributed capabilities. But introducing it without a genuine requirement can create unnecessary complexity.

 

What contributes to database cost?

Cost area

Considerations

Infrastructure 

CPU, memory, storage, network

Licensing

Commercial or enterprise licensing

Managed services 

Cloud provider charges

Data transfer

Inter-region and inter-service traffic

Backups

Backup storage and retention

Operations 

Database administration and monitoring

Engineering

Development, integration, and migration

Reliability

Replication, disaster recovery, high availability

 

For managed cloud databases, storage is only one part of the bill. Compute usage, query processing, data transfer, backups, and idle capacity can also contribute significantly.

 

Operational questions to ask

- Does the team have experience with this database?

- Can it be monitored effectively?

- How easy is backup and recovery?

- What happens during node failure?

- How are upgrades and schema migrations handled?

- Does the database support the required security and access controls?

- What is the total cost at the expected scale?

 

A simpler architecture that meets the application's requirements is often preferable to a sophisticated architecture that the team struggles to operate.

 

5.7 Evaluate Developer Experience and Ecosystem

The database must also fit the development team's working environment. Developer experience directly affects development speed, maintainability, and long-term productivity.

 

Consider the following factors:

 

a. Programming language and driver support

Does the database provide stable drivers and libraries for the application's programming languages?

 

For example:

- Java applications may use JDBC, JPA, or Spring Data.

- Python applications may use database-specific connectors and ORM libraries.

- JavaScript applications may use native drivers or query builders.

 

b. Query language and tooling

Consider whether the database provides:

- A familiar query language.

- Good IDE support.

- Query debugging and profiling.

- Migration tooling.

- Local development environments.

 

c. Ecosystem integration

Check integration with:

- Monitoring and observability platforms.

- Authentication and authorization systems.

- Backup and recovery solutions.

- Data pipelines.

- BI and reporting tools.

- Cloud infrastructure.

 

d. Documentation and community

A mature ecosystem can make it easier to troubleshoot issues, find solutions, hire engineers, and maintain the application over time.

 

e. Team expertise

Introducing a new database technology also introduces a learning curve.

 

Developer experience should not override critical technical requirements, but it should be part of the decision.

 

5.8 A Practical Database Selection Framework

Let's bring all these considerations together. Imagine we are designing an e-commerce platform. We need to support customers, product catalogs, shopping carts, orders, recommendations, and analytics.

 

We could evaluate each requirement independently.

Application requirement

Key characteristics

Database to evaluate

Customer and order management

Structured data, relationships, transactions 

PostgreSQL / MySQL

 

Shopping cart

Fast key-based access

frequent updates Redis

Product catalog

Flexible product attributes

MongoDB / PostgreSQL JSONB

Product recommendations

Relationship traversal 

Neo4j

Application event history

High-volume

timestamped data  Time-series / wide-column

Business reporting

Large scans and aggregations 

BigQuery / Snowflake

Product browsing cache

Frequent reads, repeated access

Redis

 

 

This architecture is an example of polyglot persistence: using different database technologies for different application requirements.

 

However, it is not always necessary to use six different databases.

 

For example, an initial version of the e-commerce platform might use PostgreSQL for customers, products, orders, and basic analytics, with Redis for caching.

 

As the application grows, specific workloads may justify introducing additional technologies.

 

The objective is not to use as many databases as possible. It is to use the smallest set of technologies that meets the requirements reliably.

 

Final Thoughts: Choose Based on the Problem, Not the Trend

Database technologies continue to evolve. New products frequently promise better performance, easier scalability, and simpler development.

 

But choosing a database based on popularity or technology trends can lead to unnecessary architectural complexity.

 

A relational database is still an excellent choice for many applications. A NoSQL database is not automatically faster or more scalable. A distributed database is not automatically better than a single-node database and introducing multiple databases does not automatically create a better architecture.

 

Start with the application's requirements:

·      Understand the data

·      Understand how the application accesses it

·      Define consistency, availability, and performance requirements

·      Estimate expected scale

·      Evaluate operational complexity and cost

·      Validate the decision with realistic workloads

 

The best database is not the one with the most features or the highest benchmark score. It is the one that solves the application's actual data requirements with an acceptable balance of performance, reliability, complexity, and cost.


 

                                                                                System Design Questions
Read Entire Article