AWS DynamoDB, Document DB, and Neptune

Explore AWS DynamoDB, Document DB, and Neptune to understand their unique capabilities and how they can support our database requirements.

We'll cover the following

DynamoDB, DocumentDB, and Neptune are database services offered by AWS. While they’re designed for different use cases and have unique features, all three are powerful tools for storing and retrieving data.

DynamoDB

DynamoDB is a fully managed, powerful, and flexible NoSQL database service. It offers capabilities like flexible data models (NoSQL) and automatic scalability (serverless). It’s ideal for applications that require low latency and high throughput.

DynamoDB is suitable for use cases, including gaming, ad tech, and IoT. It can be used for storing and retrieving user data, session data, metadata, and other data types.

Components

Let’s discuss the components and other entities in DynamoDB.

  • Table: A schemaless collection of data.
  • Items: A collection of attributes contained in DynamoDB tables. Each item has a primary key for unique identification. We can also add secondary indexes to items for complex searching capabilities.
  • Primary index: This allows us to uniquely identify each item in the table and is used to retrieve items based on their primary key.
    • The primary index in DynamoDB is always defined when creating a table.
    • There are two types of primary indexes:
      • Partition key: A simple primary key composed of a single attribute that determines the partition in which an item is stored.
      • Sort key: Also known as a range key, this is the second part of a composite primary key, used to sort items within the same partition. We can store multiple items with the same partition key but a different sort key.
      • Partition key and sort key: A composite primary key, composed of two attributes, where the first attribute is the partition key and the second attribute is the sort key. Together, the partition key and sort key form a composite primary key.

Note: The sort key is never used alone. It’s always part of a composite key in conjunction with the partition key. Together, they enable powerful query capabilities.

  • Secondary index: Allows us to query the data in a table using attributes other than the primary key. There are two types:
    • Global secondary index (GSI): A secondary index with a partition key and a sort key that can be different from the table’s primary key.
    • Local secondary index (LSI): Has the same partition key as the table’s primary key but a different sort key.
  • DynamoDB Streams: A feature that captures a time-ordered sequence of item-level modifications made to a table and stores this information in a log format.
    • Streams are available up to 24 hours.
    • A common use case of DynamoDB Streams is associating an AWS Lambda function with the stream to process each stream record as it’s generated.
    • We can also use DynamoDB Streams for CRR of DynamoDB tables by replicating the stream data in another table in a different region.
  • DynamoDB Accelerator (DAX): An in-memory cache that provides microsecond-level read performance for cached data. DAX is fully compatible with DynamoDB, which means we can use the same API calls and data model.

Get hands-on with 1200+ tech skills courses.