Part 10 of Learn AWS from Scratch

Which Database Should You Choose?

Relational, key-value, document, graph, time series or search. What each kind is good for, how to choose among AWS's many databases with a few simple questions, and how a real application's data layer grows step by step.

In this article
  1. Questions to start with
  2. Types of database
  3. How to decide
  4. A data layer that grows with your application
  5. Summary
  6. Test yourself

In part eight and part nine we covered RDS, Aurora and ElastiCache. But open the AWS menu and you'll find more than ten database services, and that's where people get lost.

The right question isn't "what's the best database?", because there's no single answer. The question is: what suits this particular data?

Questions to start with

Before opening any service, answer these:

Question Why it matters
What shape is the data? Linked tables, varied documents, relationships or readings over time
How will you read it? By key, with complex queries joining tables, by searching text or by aggregating millions of rows
How much reading versus writing? Heavy reads can be solved with a cache and replicas; heavy writes need a different design
How big, and how fast is it growing? Ordinary gigabytes, or data that grows without a ceiling
How accurate must it be? A money transfer needs strict transactions; a like count can tolerate delay
How much can you manage? A small team prefers a service that scales by itself
What does your team know? Existing knowledge spares you many mistakes

Types of database

Type Shape of the data AWS service Example
Relational Linked tables and transactions RDS and Aurora Orders, accounts, invoices
Key-value A value fetched by its key, at huge scale DynamoDB Carts and user profiles
Document JSON with varied fields DocumentDB and DynamoDB Catalogs and content
In-memory Fast data ElastiCache and MemoryDB Caching and sessions
Wide-column Cassandra-style rows with heavy writes Keyspaces Existing Cassandra systems
Graph Connections between things Neptune Social networks and fraud detection
Time series Readings over time Timestream for InfluxDB Sensors and metrics
Search Text you search inside OpenSearch Site search and logs
Analytics Aggregation over huge data Redshift Management reports
Files Files of any kind S3 with Athena Logs and archives

Relational or NoSQL?

This is the first decision, and the real difference is in how you think:

Relational (SQL) NoSQL
Design Design the tables, then write any query Define the queries first, then design around them
Queries Flexible, with table joins Limited, and fast along the path you designed
Transactions Strong Varies by service
Scaling Reads are easy; writes usually mean a bigger server Horizontal, with steady performance as it grows

Services you'll come across

  • DynamoDB: serverless key-value with steady performance at any size. We cover it in part twenty-one.
  • DocumentDB: documents compatible with MongoDB, which suits you if you're moving an existing MongoDB application.
  • MemoryDB: fast memory like Valkey but with durable data, so you can use it as a primary database and not just a cache.
  • Keyspaces: compatible with Apache Cassandra, with no servers to manage.
  • Neptune: for data whose value lies in relationships, such as "friends of my friends who bought this".
  • Timestream for InfluxDB: for sensor readings and metrics. The older LiveAnalytics edition is closed to new customers.
  • OpenSearch: text search and log analysis, usually a copy of your data rather than the main source.
  • Redshift: a data warehouse for huge reports. We cover it in part twenty-three.

How to decide

Go through the questions from top to bottom, and the first "yes" is your starting point:

A temporary copy to speed up reads? ElastiCache Yes No Searching inside text or logs? OpenSearch Yes No Reports across huge volumes of data? Redshift, Athena Yes No Is the value in links between things? Neptune Yes No Readings over time, from sensors say? Timestream Yes No Simple key lookups at huge scale? DynamoDB Yes No Ordinary application data RDS, Aurora
Start at the top: each "yes" gives you a service to begin with, and if nothing applies, a relational database is the default.

This is a starting guide, not a law. One application usually uses more than one type, with each kind of data going where it fits.

A data layer that grows with your application

You don't need all this from day one. Imagine an online store growing over time:

  1. Launch: a single RDS database is enough. Once you take real orders, turn on Multi-AZ.
  2. More visitors, heavier reads: add ElastiCache for main pages and sessions.
  3. Reports start slowing the site: send them to a read replica.
  4. Product search is weak: add OpenSearch and fill it from the database.
  5. Management wants years of analysis: move the data to S3 with Athena or Redshift.
  6. Visitors from around the world: move to Aurora Global Database.

Each step came after a real problem you measured, not before it. Every extra service means more cost, more complexity and one more thing that can fail.

Common mistakes

  • Choosing NoSQL because it "scales": then discovering you need queries you didn't design for.
  • Running reports on the production database: one heavy query slows the whole site.
  • Storing files inside the database: put them in S3 and keep the link in the database.
  • Treating the cache as a source of truth: if it's lost, nothing important should go with it.
  • Multi-AZ in development: double the cost, usually for no benefit.

Summary

  • Ask about the shape of the data and how you'll read it before any service name.
  • Start relational unless you have a clear reason not to.
  • One application uses more than one type, with each kind of data going where it fits.
  • Add each service when you measure a real problem, not before.

Test yourself

Before you move on, try these questions to check you've got this part. Each one is a practical scenario, and the explanation appears once you answer.

Question 1 of 5

A clinic is building a booking system with appointments, patients and payments. The data is linked, payments need strict transactions, and the small team doesn't yet know all the reports it will need. Where should it start?

Show the answer

Correct answer: B

Linked data, transactions and queries you can't fully predict all point to a relational database. It's the sensible default unless there's a clear reason otherwise.

  • A: You'd design around known queries up front, and new reports would be hard to add.
  • C: A cache isn't a source of truth, so it can't be where payments live.
  • D: Neptune suits deep webs of connections, not ordinary linked tables.

Review: Relational or NoSQL? in this part, and Choosing an AWS database service in the AWS docs.

Question 2 of 5

A social app wants to suggest "people you may know" by following friends of friends across several hops, with fast responses. Which service fits best?

Show the answer

Correct answer: D

The value here is in the relationships themselves, and Neptune is built to walk through large numbers of them with low latency.

  • A: This works for one or two hops, but joins get heavy as the hops increase.
  • B: You could store ready-made lists, but something still has to work them out.
  • C: This is for readings over time, and has nothing to do with relationships.

Review: Services you'll come across in this part, and Choosing an AWS database service in the AWS docs.

Question 3 of 5

Ten thousand sensors send a temperature reading every minute, and engineers want hourly averages for each sensor over the last week. Which service was built for this?

Show the answer

Correct answer: A

These are readings over time, which is what a time series database is built to store and aggregate.

  • B: This is for connections between things.
  • C: This is for JSON documents with varied fields.
  • D: This is mainly for searching text and analyzing logs.

Review: Types of database in this part, and What is Timestream for InfluxDB? in the AWS docs.

Question 4 of 5

A company wants to move an existing MongoDB application to a managed AWS service with the fewest code changes. Which service fits?

Show the answer

Correct answer: C

DocumentDB is compatible with MongoDB, so the application's document model and much of its code can stay as they are.

  • A: This has a different API and data model, so the data access code would be rewritten.
  • B: This is compatible with Cassandra, not MongoDB.
  • D: This is relational, so the documents would need redesigning as tables.

Review: Services you'll come across in this part, and What is Amazon DocumentDB? in the AWS docs.

Question 5 of 5

A sales team wants reports across five years of orders, which means billions of rows, and the queries must not slow down the production database. Which two approaches fit? (Choose two.)

Show the answer

Correct answer: B + E

Both move heavy analysis away from production. Redshift suits frequent, heavy reports, and Athena suits occasional questions without any servers to run.

  • A: One heavy query can still hurt anything else running then, and it's a relational database that isn't built for this scale of analysis.
  • C: A cache is a temporary copy, and far too small and costly for five years of data.
  • D: The standby in a Multi-AZ instance can't be read from.

Review: Common mistakes in this part, and What is Amazon Athena? in the AWS docs.

That completes the databases section. Your application now runs, scales and keeps its data safe, but how do visitors reach it by your site's name? That's the next section's subject, starting in part eleven with DNS and Route 53.