Header Ads

Header ADS

DynamoDB Introduction

1️⃣ DynamoDB কি?

DynamoDB হলো fully managed NoSQL database service, যা Amazon Web Services (AWS) প্রদান করে।

Main characteristics:

  1. NoSQL: Key-Value & Document store

  2. Fully Managed: Server maintenance, patching, scaling দরকার নেই

  3. Ultra Fast: Millisecond latency

  4. Scalable: Auto-scaling support, high throughput

  5. Secure: Data encryption, IAM policies, fine-grained access control

প্রসিদ্ধ উদাহরণ:

  1. Gaming leaderboards

  2. IoT event storage

  3. High-traffic websites

  4. Mobile banking apps


2️⃣ SQL vs DynamoDB (Mindset)

DynamoDB SQL database এর মতো নয়।

FeatureSQLDynamoDB
Table Yes   Yes
RowRecord  Item
Column     Fixed  Attribute (Flexible)
SchemaFixed   Flexible
JoinYes     No (denormalization)
QueryComplex   Access pattern based

Key insight:
DynamoDB এ “Query pattern first, schema later”
SQL এ তুমি schema design করে query adjust করো, DynamoDB তে query dictate schema


3️⃣ DynamoDB Structure

3.1 Table

  1. Main container for data

  2. প্রতিটি table একটি primary key দিয়ে uniquely identify হয়


3.2 Item

  1. Row equivalent

  2. JSON-like structure

  3. Flexible attributes

Example:

{
  "user_id": "1",
  "name": "Ali",
  "age": 24,
  "hobbies": ["coding", "football"]
}

3.3 Attribute

  1. Column equivalent

  2. Type can be:

    1. S → String

    2. N → Number

    3. BOOL → Boolean

    4. L → List

    5. M → Map (JSON object)


3.4 Primary Key

Two types:

1️⃣ Partition Key (HASH) — Unique identifier
2️⃣ Sort Key (RANGE) — Optional, to create composite key

Example:

user_idtimestampaction
11685001login
11685005logout

user_id = partition key

timestamp = sort key


4️⃣ Secondary Indexes

DynamoDB supports alternate query patterns using:

1️⃣ Global Secondary Index (GSI)
2️⃣ Local Secondary Index (LSI)

Purpose: Query on attributes other than primary key


5️⃣ Query vs Scan

Query: Efficient, uses primary key or index → O(1) or O(log n)

Scan: Reads entire table → Expensive → O(n)

Pro tip: Always design table for query first, minimize scans


6️⃣ Consistency

  • Eventually Consistent: Default, faster, cheaper

  • Strongly Consistent: Reads latest data, slightly slower


7️⃣ Capacity Modes

1️⃣ On-Demand: Pay per request, auto scaling
2️⃣ Provisioned: Specify read/write capacity, cheaper for stable load


8️⃣ Real-World Best Practices

  1. Denormalization is normal: Embed related data, don’t rely on joins

  2. Access Pattern Driven: Table design based on queries

  3. Use Indexes wisely: GSI/LSI for alternate queries

  4. Keep items small: DynamoDB bills per KB read/write

  5. Use TTL for temporary data: Automatic deletion


🔥 Key Takeaways

  • DynamoDB = NoSQL + AWS managed + Key-Value + Document store

  • Design schema based on query patterns

  • Partition Key & Sort Key are most important

  • GUI only for visualization; real operations via CLI/SDK

  • Secondary Indexes enable alternate queries

  • Query ≠ Scan → Always optimize queries



Powered by Blogger.