USD ($)
$
United States Dollar
Euro Member Countries
India Rupee

DynamoDB and NoSQL Data Design

Lesson 9/36 | Study Time: 25 Min

Amazon DynamoDB is a fully managed NoSQL database service provided by AWS, designed for applications that require consistent, single-digit millisecond latency at any scale.

Unlike traditional relational databases, DynamoDB uses a flexible data model based on key-value and document store paradigms, making it ideal for highly scalable, high-throughput applications.

Understanding the principles of NoSQL data design within DynamoDB is crucial to leveraging its full potential for performance, scalability, and cost-efficiency in cloud-native applications.

Basics of DynamoDB


DynamoDB stores data in tables, each of which contains multiple items, analogous to rows in relational databases. Each item is a collection of attributes (similar to columns), but unlike a fixed relational schema, items can have varying attributes.

The core concept of DynamoDB is its ability to scale horizontally by dividing data across partitions based on partition keys.


Table Design in DynamoDB

A well-designed DynamoDB table ensures scalability, cost-efficiency, and quick data retrieval for dynamic workloads. The main concepts below explain how keys and indexes shape an effective database structure:


1. Primary Key Structure: DynamoDB requires specifying a primary key for each table, which uniquely identifies items.


  • Partition Key (Hash Key): A single attribute used to distribute data and request traffic across partitions.
  • Composite Primary Key: Consists of a partition key plus a sort key (range key). This allows grouping related items within a partition and enables range queries.


2. Secondary Indexes: To efficiently query data on attributes other than the primary key, DynamoDB supports:


  • Global Secondary Index (GSI): A secondary index with a different partition and sort key than the base table, offering flexibility in querying.
  • Local Secondary Index (LSI): Uses the same partition key but a different sort key, enabling alternate sorting and query paths within a partition.


Data Modeling Principles


NoSQL design in DynamoDB calls for a different approach than normalized relational models:


  • Emphasize single table design to consolidate multiple entity types into one table using composite keys and attribute patterns, reducing the need for costly joins.
  • Use denormalization and data duplication strategically to optimize performance.
  • Model access patterns upfront to design keys and indexes that support efficient queries.
  • Leverage attribute projections on indexes to improve read performance.


Performance Considerations ( Image )


  • Provisioned throughput is measured in Read Capacity Units (RCU) and Write Capacity Units (WCU), dictating how many reads and writes per second a table can handle.
  • Use Auto Scaling to adjust capacity based on demand.
  • Employ DynamoDB Streams for capturing table data modifications to enable event-driven applications or data replication.
  • Consider transaction support for atomic and consistent operations across multiple items, ensuring data integrity.


Security and Integration


DynamoDB integrates with AWS Identity and Access Management (IAM) for fine-grained access control. Data can be encrypted at rest and in transit using AWS Key Management Service (KMS). Integration with AWS Lambda facilitates seamless serverless data processing on data changes.


Practical Use Cases ( Image )


DynamoDB fits environments requiring:


  • High read/write throughput for gaming leaderboards, IoT telemetry, or real-time bidding.
  • Flexible schemas for user profiles, catalogs, or content management systems.
  • Event logging and session management with predictable low latency.
Samuel Wilson

Samuel Wilson

Product Designer
Profile
new offers till new year 2025
new offers till new year 2025
View Courses