liveBook · Manning

DynamoDB

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

Amazon DynamoDB is a managed NoSQL database service providing low-latency access to scalable key-value and document data.

DynamoDB is a managed NoSQL database for application data. It stores items in tables and identifies each item by a key. AWS operates the database, so you do not install software, maintain machines, or perform updates. Your application accesses it through an API rather than SQL. section 12.1 section 12.10

Design the keys around the data your application needs to retrieve. A partition key identifies an item; adding a sort key lets items share a partition key and be queried in sort-key order. A global secondary index supports efficient queries on another attribute. A scan searches the whole table, but is inefficient for frequent lookups. section 12.15

A task application

A Node.js command-line application can keep users and tasks in separate DynamoDB tables. Its commands add users and tasks, mark tasks done, and list tasks with filters. It sends requests through the AWS SDK; an existing SQL application cannot simply switch databases without changes to its code and data model. section 12.1 section 12.3

Listing 12.4 DynamoDB: Creating an item
const params = {
  Item: {                           #1
    attr1: {S: 'val1'},             #2
    attr2: {N: '2'}                 #3
  },
  TableName: 'app-entity'           #4
};
db.putItem(params, (err) => {       #5
  if (err) {                        #6
    console.error('error', err);
  } else {
    console.log('success');
  }
});

A minimal Node.js putItem call shows the table name, an item with typed attribute values, and error handling. section 12.3

Managed does not mean unattended. Restrict data access with IAM, monitor capacity, choose between on-demand and provisioned capacity, and configure backups so you can recover from accidental deletion or corrupted items. On-demand capacity suits spiky workloads. Reads can return stale data unless you request strong consistency; reads from a global secondary index are always eventually consistent. section 12.10 section 12.15

DynamoDB does not run inside your VPC. An application in a private subnet can reach its API through a NAT gateway, but a DynamoDB VPC endpoint avoids that dependency. For applications reacting to changes, DynamoDB Streams exposes item writes. Conditional updates can also support optimistic locking, but the application must implement the version check. section 12.12 section 12.4 section 16.3.2

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Works through SDK item operations, retrieval choices, and operational decisions; does not treat DynamoDB as a drop-in SQL replacement.
Examples
Builds a Node.js task CLI and stores image-processing records for an Express web service.
What it assumes
Introduces DynamoDB tables and Node.js setup, while requiring application code rather than assuming an existing SQL application will work unchanged.
What you can do after
Build it from scratch using the AWS SDK to store and retrieve items, then operate it with capacity monitoring and backups.
How it connects
Connects primary keys and secondary indexes to querying, IAM to access control, and VPC endpoints to private-subnet access.

Also explained in

Compare how 2 books explain DynamoDB →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.