liveBook · Manning

DynamoDB item

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

A DynamoDB item is a record of attributes stored as a single entry in a DynamoDB table.

A DynamoDB item is one record in a table, comparable to a row in a relational database. It is a collection of attributes, and each attribute is a name-value pair. Attribute values may be scalar, multivalued, or JSON documents. section 12.1 section 12.2

Keep these characteristics in mind when designing and using items:

  • Allow items in one table to have different non-key attributes because DynamoDB does not enforce a fixed schema. section 12.2
  • Define the primary-key attributes because the key uniquely identifies an item and supports retrieval, updates, and deletion. section 12.2.1
  • Use either a partition key alone or a partition key combined with a sort key, depending on the table design. section 12.2.1 section 12.4.1
  • Send item operations through the AWS SDK and DynamoDB API rather than treating the table like a SQL database. section 12.1 section 12.3

A user item

A user item in the todo-user table can contain uid, email, and phone attributes. With uid as the partition key, getItem retrieves Emma by supplying uid set to emma; a task item can instead use both uid and tid. section 12.2.1 section 12.4.1

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');
  }
});

See the smallest AWS SDK request for creating an item: provide an Item map, typed attribute values, and a table name, then call putItem. section 12.3

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

How deep it goes
Defines attributes, value types, schema flexibility, and key-based CRUD, but defers update implementation.
Examples
Uses user records with uid, email, and phone, plus task records identified by uid and tid.
What it assumes
Assumes basic JavaScript and AWS SDK familiarity while defining DynamoDB item and key terminology explicitly.
What you can do after
Build it from scratch by creating, retrieving, and deleting keyed items with the AWS SDK.
How it connects
Connects DynamoDB tables, attributes, primary keys, partition keys, sort keys, and AWS SDK operations.

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.