# Amazon DynamoDB

> A key-value database that answers in milliseconds no matter how big the table gets.

- Level: Basic
- Topics: AWS
- URL: https://tidbit.legios.com.ar/amazon-dynamodb/
- In Spanish: [Amazon DynamoDB](https://tidbit.legios.com.ar/es/amazon-dynamodb/)

**DynamoDB** is AWS's NoSQL database. Instead of tables with rows and columns joined by SQL, it stores **items** (JSON-like documents) and finds them by a **key** you choose, such as a user id or an order number. Fetching an item by key takes a few milliseconds whether the table holds a thousand items or a billion.

There is no server to size: you pay per read, per write and per gigabyte stored, and AWS spreads the table over as many machines as it needs. It is fully managed, replicated across three Availability Zones, and can keep live copies in other Regions. The catch is that it only does fast what it was designed for: getting items by key. A question like 'all orders over 100 dollars last March' needs either a careful table design or a different tool, such as Amazon RDS or Amazon Athena.

Typical uses: shopping carts, user sessions and profiles, game leaderboards, the state behind a mobile app. Amazon's own retail site leans on it for its busiest shopping days, which is roughly the scale it was built for.

## An analogy

A coat check. You hand over a coat, get a numbered ticket, and later get the coat back instantly by showing the ticket. Asking the attendant for 'all the blue coats' is not what the system is for.

## Keep in mind

- You access items by a key you choose; design the key around the questions you will ask.
- Serverless pricing: per read, per write and per gigabyte, with no instance to manage.
- Reads take single-digit milliseconds at any table size.
- Great for carts, sessions and profiles; a poor fit for ad hoc reporting.

## Go deeper

- [What is Amazon DynamoDB? (official docs)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Introduction.html)
- [Amazon DynamoDB](https://aws.amazon.com/dynamodb/)

## Related terms

- [NoSQL](https://tidbit.legios.com.ar/nosql/): Databases that store data in shapes other than tables with fixed columns.
- [SQL](https://tidbit.legios.com.ar/sql/): The language you use to ask a database questions.
- [JSON](https://tidbit.legios.com.ar/json/): The plain-text format programs use to hand each other structured data.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [Regions and Availability Zones](https://tidbit.legios.com.ar/regions-and-availability-zones/): Where AWS physically lives: cities worldwide, each split into separate data centers.
- [Amazon RDS](https://tidbit.legios.com.ar/amazon-rds/): A ready-made relational database that AWS keeps patched, backed up and running.
- [Amazon Athena](https://tidbit.legios.com.ar/amazon-athena/): Run SQL directly on files sitting in S3, with no database to set up.
- [Amazon](https://tidbit.legios.com.ar/amazon/): An online store with its own delivery network, and the company that runs AWS.
