DEV Community

Adish Ghimire
Adish Ghimire

Posted on

How Amazom Dyanamo DB Works?

Amazon DynamoDB is a fully managed NoSQL database service provided by Amazon Web Services (AWS) that offers fast and predictable performance with seamless scalability. Here’s a detailed overview of how DynamoDB works:

Key Concepts
Tables: The primary structure that holds data in DynamoDB. Each table is a collection of items, and each item is a collection of attributes.
Items: Similar to rows in a relational database, items are the individual records in a table. Each item is uniquely identified by a primary key.
Attributes: The data elements that compose an item, analogous to columns in a relational database.
Primary Key
Partition Key: A single attribute primary key, where the value is hashed to determine the partition where the item is stored.
Composite Key: Consists of a partition key and a sort key. The partition key determines the partition, and the sort key allows multiple items with the same partition key to be stored together and queried in sorted order.
Data Model
Schema-less: Unlike traditional databases, DynamoDB does not require a predefined schema. Each item in a table can have a different number of attributes.
Data Types: Supports scalar types (e.g., String, Number, Binary), document types (e.g., List, Map), and sets (e.g., String Set, Number Set).
Read and Write Operations
Read Operations:
GetItem: Retrieves a single item by primary key.
Query: Retrieves multiple items using the primary key and an optional sort key.
Scan: Retrieves all items in a table, with optional filtering.
Write Operations:
PutItem: Creates a new item or replaces an existing item.
UpdateItem: Modifies one or more attributes of an existing item.
DeleteItem: Deletes an item by primary key.
Consistency Models
Eventually Consistent Reads: Returns data that might not reflect the results of a recently completed write operation. This is the default and offers higher throughput.
Strongly Consistent Reads: Returns the most up-to-date data, reflecting all writes that received a successful response prior to the read.
Scaling and Performance
Provisioned Capacity: Allows specifying the number of read and write capacity units for a table.
On-Demand Capacity: Automatically scales to accommodate workloads without the need to specify capacity.
Auto Scaling: Adjusts the provisioned throughput automatically based on traffic patterns.
Indexing
Secondary Indexes: Provides more flexible querying capabilities.
Global Secondary Index (GSI): Allows querying on non-primary key attributes. Consists of a partition key and an optional sort key.
Local Secondary Index (LSI): Allows querying on non-primary key attributes within the same partition key. Consists of the same partition key but a different sort key.
Transactions
ACID Transactions: Supports atomicity, consistency, isolation, and durability across multiple items and tables. Allows operations to be grouped and executed together, ensuring data integrity.
Streams and Triggers
DynamoDB Streams: Captures data modification events (e.g., inserts, updates, deletes) in a table. Can be used to trigger AWS Lambda functions or replicate data to other services.
Security and Access Control
IAM Policies: Controls access to DynamoDB resources using AWS Identity and Access Management (IAM).
Encryption: Encrypts data at rest using AWS Key Management Service (KMS). Also supports TLS for data in transit.
Integration with Other AWS Services
AWS Lambda: Can be triggered by DynamoDB Streams for real-time processing.
Amazon Redshift: Can be used to import data for complex analytics.
AWS Glue: Provides ETL (Extract, Transform, Load) capabilities to move data between DynamoDB and other data stores.
Use Cases
Web Applications: High-traffic web applications requiring low-latency data access.
IoT Applications: Storing and querying large volumes of time-series data.
Gaming Applications: Leaderboards, player data, and game state management.
Mobile Applications: Offline data synchronization and real-time data access.
By understanding these concepts and features, you can leverage DynamoDB to build scalable and high-performance applications on AWS.

Image description

{% embed  %}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)