Choose the Right Data Storage

Starting from the data model and access patterns, not product names: relational, NoSQL, object, analytics and specialized storage, and a candidate storage design for Apex.

  • Intermediate to advanced
  • About 21 minutes
  • Includes an exercise and a knowledge check

The concept Ask the right question

The wrong question is: should we use PostgreSQL, DynamoDB or MongoDB? The right question is: what data do we need to store, how will applications use it, and what consistency and performance does the business require? Apex's core entities are payments, settlements, providers, loans, reconciliation results, exceptions, adjustments and audit records, and they are related: one loan has many payments, a payment may wait unmatched for settlement, an adjustment needs approval and an audit record.

Four storage categories as four kinds of storage room. Relational database, a filing cabinet of linked folders: payments, settlements, matches, exceptions and approvals; read with joins and transactions; strong consistency. NoSQL database, a wall of labeled lockers: key-based lookups at very large scale with predictable access. Object storage, a warehouse of boxes: original settlement files, archives, evidence and exports; read or write whole files. Analytics storage, a library: years of history for reporting; large scans and aggregations.
Different data, different homes. They solve different problems and are not interchangeable.

In detail What each kind is good at

StorageUseful whenWatch out for
Relational (PostgreSQL, Aurora, RDS, SQL Server)Well-defined relationships, constraints, joins, reliable transactional updatesSchema evolution, horizontal scaling, expensive queries, write contention. Consistency is not identical everywhere: it depends on the engine, the isolation level and whether you read from a replica that lags
NoSQL (DynamoDB, MongoDB, Cassandra)Predictable key-based access at very large scale; flexible documentsPartition keys, hot partitions, indexing, duplicated data. Consistency settings vary by product. Many support transactions (DynamoDB and MongoDB do), each with its own limits to check
Object storage (S3 and similar)Large files and unstructured contentIt is not a transactional database
Search indexFlexible full-text investigationKeeping it in sync with the source
Data warehouse or lakehouseHistorical analyticsFreshness and cost of large scans
Time-series databaseTelemetry and sensor readingsRetention and downsampling
In-memory cacheTemporary fast readsStale data and cache invalidation

The method Decide from access patterns

  • What are the main reads, and the main writes?
  • Must several records change atomically together?
  • Do queries need relational joins?
  • How often does the schema change, and how many records will there be?
  • How long must records be kept?
  • What query latency and which consistency model are acceptable?
  • How do backups and recovery work?

Apply it A candidate design for Apex

DataCandidate storageWhy
Payments, settlements, matches, exception state, approvalsRelational databaseRelated records, transactions, constraints, audit-friendly
Original settlement and provider filesObject storageWhole files kept as received, for evidence and replay
Free-text investigation searchSearch index, only if justifiedAdd it only if users need flexible search
Long-term reporting historyAnalytics platform, only if neededWhen reporting load outgrows the transactional database
Audit historyAppend-only tables, plus write-once object storage for archived copiesRecords must not be changed or deleted before their retention period ends

Audit records need three answers before you design them: how long they must be kept (Apex: seven years, from the compliance policy), how they are protected from change (append-only tables, and write-once storage such as S3 Object Lock for archives), and how they are deleted when the period ends. Deletion must follow a policy that legal and compliance have approved, including legal holds that pause it. Never decide retention or deletion yourself.

Practice Place six kinds of data

Practical exercise

Where does it belong?

Choose storage for each item and state your consistency and retention assumption.

  1. Payment transaction records.
  2. Settlement source files.
  3. Exception investigation state.
  4. Long-term historical reporting.
  5. Operational search data.
  6. Audit history.
Show sample answers
  • Payments: relational; strong consistency; retained for the financial retention period.
  • Settlement files: object storage, unchanged as received; retained as evidence.
  • Exception state: relational, in the same transactions as the matching results.
  • Historical reporting: analytics storage fed nightly, if the volume requires it.
  • Operational search: a search index only if users need free-text search; rebuilt from the source.
  • Audit history: append-only relational records, never updated or deleted, retained per compliance.

3 questions

Check your understanding

1. Why might a relational database suit financial transaction records?
2. Where should original settlement files go?
3. What should drive a database choice?
Answer every question to submit.

What you can do now

  • Start a storage decision from the data model.
  • Explain what relational, NoSQL, object and analytics storage are good at.
  • Decide storage from access patterns, consistency and retention.