Ravindra BagaleCourses & study guides English Track your progress

DynamoDB Data Modeling आणि Single-Table Design सोप्या भाषेत

Amina व Vikram: MySQL-like -> Scan. Patterns first + single-table. Put/Get = CRUD/SDK link.

या chapter मध्ये तुम्ही काय शिकाल

  • Everyday story
  • Why/What/How
  • Commands + meaning
  • Industries
  • Lab + cleanup

1. रोजचे उदाहरण: एक वही

Kirana वही: tabs=PK. Single-table labels. Tax वेगळे. Meera: patients एकत्र; firmware वेगळे.

2. Vertical steps

Why -> What -> How -> Lab -> CleanupWhyWhatHowLabCleanup
Cleanup

3. हे का लागतं?

हे का लागतं?

Questions first. Attribute-first -> Scan. Hot = Get/Query.

4. हे काय आहे?

हे काय आहे?

एक table + prefixes. Related = एक Query. Unrelated = multi-table.

5. कसं करायचं

कसं करायचं (step by step)

  1. 5-15 patterns.
  2. एक partition.
  3. SK ranges.
  4. EntityType.
  5. Samples.
  6. GSI later.

6. CartLite

USER orders; ORD lines; PROD GetItem.

7. Many-to-many

Kenji edges; thin; txn later.

8. Commands: output आणि अर्थ

aws dynamodb create-table --table-name lab-dda-shop \
  --attribute-definitions AttributeName=PK,AttributeType=S AttributeName=SK,AttributeType=S \
  --key-schema AttributeName=PK,KeyType=HASH AttributeName=SK,KeyType=RANGE \
  --billing-mode PAY_PER_REQUEST --region ap-south-1
# Output: TableStatus CREATING then ACTIVE
aws dynamodb put-item --table-name lab-dda-shop --item '{"PK":{"S":"USER#u100"},"SK":{"S":"PROFILE"},"EntityType":{"S":"User"},"name":{"S":"Ananya Rao"}}'
aws dynamodb query --table-name lab-dda-shop --key-condition-expression "PK = :pk" --expression-attribute-values '{":pk":{"S":"USER#u100"}}'
# Output: Count>=1. Meaning: item collection for that user PK.

create-table lab; put User; query = collection.

9. Industry stories

  • Retail
  • Logistics
  • EdTech
  • Bank
  • SaaS
  • Media

10. Lab

कसं करायचं (step by step)

  1. Patterns+draw.
  2. Create+Query.
  3. Delete.

Cleanup

  1. Lab delete करा.
  2. Confirm gone.

11. Access-pattern workshop (आधी कागदावर)

  1. प्रत्येक screen/API लिहा.
  2. प्रत्येकासाठी key/query English मध्ये.
  3. Relationships mark करा.
  4. Range गरज गोल करा.
  5. मगच PK/SK/GSI.
  6. Peak per PK.
  7. Entity JSON नमुना.
  8. Peer review.

12. Copy-paste DynamoDB CLI starters

# Region habit for this series
export AWS_DEFAULT_REGION=ap-south-1

# Describe + sample
aws dynamodb describe-table --table-name ShopApp
aws dynamodb scan --table-name ShopApp --max-items 3

# Query by PK (replace names)
aws dynamodb query --table-name ShopApp   --key-condition-expression "PK = :pk"   --expression-attribute-values '{":pk":{"S":"USER#u123"}}'

# On-demand capacity mode check
aws dynamodb describe-table --table-name ShopApp   --query 'Table.BillingModeSummary'

# Streams status
aws dynamodb describe-table --table-name ShopApp   --query 'Table.StreamSpecification'

13. अजून industry stories

  • Retail cart single-table
  • Gaming leaderboard shard
  • IoT time-series TTL
  • Clinic conditional Put
  • Fintech audit Streams
  • Travel global tables

14. Glossary

Termअर्थ
PKPartition ठरवणारी key
SKPartition आतील क्रम
Item collectionएक PK चे सर्व items
GSIAlternate index
LSISame PK, वेगळा SK
RCU/WCUProvisioned units
Conditional writeCondition true तरच write
Stream viewStream मध्ये काय येतं

15. Practice: मोठ्याने explain

  1. 60s access patterns first.
  2. 60s hot + shard.
  3. 60s GSI vs LSI.
  4. 60s capacity modes.
  5. 60s version lock.
  6. 60s Streams audit.
  7. Record ×2.

16. Safe lab hygiene

  • Budget alert.
  • lab- prefix.
  • On-demand labs.
  • Delete after.
  • DLQ required.
  • Owner+Expiry tags.
  • Intro chapter
  • CRUD survey
  • CLI chapter
  • SDK chapter
  • Serverless projects

18. Single-table sketch pad

Console आधी एक mentally table. Shop: USER#, ORD#, ITEM#, PROD#.

EntityPKSKAttrs
UserUSER#u1PROFILEname, city
OrderUSER#u1ORD#...total, status
Order itemORD#o9ITEM#sku1qty, price
ProductPROD#sku1METAtitle, stock

19. दहा oral drills

  1. Access pattern?
  2. PK prefixes?
  3. Hot symptom?
  4. Sparse GSI?
  5. LSI timing?
  6. On-demand bill?
  7. attribute_not_exists?
  8. View type trade-off?
  9. Poison loop?
  10. Which chapter for Put?

20. Capacity / throttle drill

  1. CW metrics उघडा.
  2. Mode note.
  3. RCU/WCU लिहा.
  4. Hottest PK.
  5. Mitigation.
  6. Budget alert.
  7. GSI audit.
  8. Streams audit.

21. Condition cheatsheet

# Create-once
attribute_not_exists(PK)

# Optimistic lock
version = :v

# Stock / seat
stock > :zero
#status = :free

# Combine
attribute_not_exists(PK) AND #type = :user

Conditions = seatbelt. SDK chapter = full samples.

22. Streams consumer checklist

  • View type.
  • DLQ.
  • Idempotent.
  • IteratorAge.
  • No loop.
  • Fan-out.
  • Lab disable.
  • Sequence.
  • No duplicate verbs.
  • Projects later.

24. अधिक oral drills

  1. 45s PM.
  2. Chat PK/SK.
  3. 3 metrics.
  4. Refuse GSI.
  5. Txn story.
  6. ALO.
  7. Scan->Query.
  8. Cleanup.

25. Teacher story: notebook → database

Ravindra Sir नी एका दुकानात सगळं एका notebook मध्ये बघितलं — customer, order, payment. unpaid bills शोधायला पाने उलटायला लागत. DynamoDB single-table म्हणजे तोच notebook नीट लेबल (PK/SK) आणि गरज असेल तरच दुसरी tab (GSI). दहा वेगळे books तयार करू नका जोपर्यंत खरंच दहा वेगळे व्यवसाय नाहीत.

Meera (clinic), Omar (travel), Aisha (retail) एकत्र design करतात तेव्हाही आधी कागद: screen यादी, key sketch, sample JSON, peer review. Console शेवटी. म्हणूनच ही deep series PutItem पुन्हा लिहित नाही — intro आणि CRUD ला link करते.

26. सोळा mini tasks (self-check)

  1. Cart साठी तीन access patterns.
  2. User + orders PK/SK.
  3. एक hot anti-pattern.
  4. 40s मध्ये write sharding.
  5. GSI vs LSI without notes.
  6. Sparse index projection का?
  7. Flash sale mode.
  8. पाच bill line items.
  9. Create-once condition शब्दात.
  10. Version lock वर्णन.
  11. Txn कधी?
  12. Audit view type.
  13. दोन consumer safety rules.
  14. Stream lag metric.
  15. PutItem CLI कुठे?
  16. Lab cleanup checklist.

27. मराठी classroom lines

  • Mantra: patterns first.
  • Hot = गर्दी.
  • GSI vs LSI.
  • Modes.
  • Seatbelt.
  • ALO.

28. Hindi bridge lines

  • Patterns first.
  • Hot load.
  • GSI/LSI.
  • Modes.
  • Txn.
  • Idempotent.

29. सामान्य errors आणि fixes

प्रत्येक row = खरी चूक. Panic करण्याआधी fix वाचा.

Error / लक्षणFix
MySQL-firstPatterns
Email PKOpaque
GiantSplit
ForcedSplit
Bad SKISO
No typeAdd
ScanQuery
No drawDraw
CopyLink

30. Troubleshooting checklist

  1. PK+region.
  2. SK.
  3. ORD PK.
  4. Hot.
  5. RDS?

31. FAQ

प्र. Single table always?

Related patterns साठी हो; religion नाही.

प्र. RDS अजून?

Joins/SQL reports साठी हो — intro chapter.

प्र. Scan वाईट?

Hot path = Query/Get; Scan rare.

प्र. Put/Get कुठे?

CRUD/CLI/SDK chapters — link.

प्र. Mandatory?

No.

प्र. Count?

Patterns.

प्र. Put?

Links.

प्र. PK?

Migrate.

32. Interview Q&A

प्र. Pattern?

English need.

प्र. Prefix?

Types.

प्र. Multi?

Unrelated.

प्र. Adj?

Edges.

प्र. MNC

Partitions.

प्र. Scans?

Gate.

33. Tips — English, मराठी आणि हिंदी

Ravindra Bagale's Tip (EN)

Questions first; keys are answers.

Ravindra Bagale's Tip (MR)

आधी प्रश्न; keys उत्तरे.

Tip (HI)

पहले सवाल, फिर keys।

घरी करून बघा

  1. 8 patterns.
  2. Draw.
  3. CRUD.

थोडक्यात सांगायचं तर

  1. Patterns first.
  2. Prefixes.
  3. Collections.
  4. Link.

उजळणी, मुलाखत आणि तुलना cards

हा lesson काही मिनिटांत revise करा. Cards phone वर save करा किंवा PNG download करा. प्रत्येक card वरचा QR हा lesson उघडतो.

उजळणी card: Access patterns first. Keys before patterns = pain. Screens → Query → keys. Paper → JSON → review → console. Retail discipline.
उजळणी card: Access patterns first · PNG download करा · Card page उघडा
उजळणी card: Single-table sketch. ER-per-entity fights Query. Prefixes + overloaded SK. List → matrix → edges → Query. Whiteboard first.
उजळणी card: Single-table sketch · PNG download करा · Card page उघडा
तुलना: Single-table vs Multi-table. Single-table: One Query shape. Multi-table: Clear boundaries.
तुलना: Single-table vs Multi-table · PNG download करा · Card page उघडा
तुलना: ER-first vs Access-first. ER-first: ER then pain. Access-first: Patterns then keys.
तुलना: ER-first vs Access-first · PNG download करा · Card page उघडा
मुलाखत card: Access patterns का?. Opener. Keys follow access. Two patterns → keys.
मुलाखत card: Access patterns का? · PNG download करा · Card page उघडा
मुलाखत card: Single-table काय?. Def. One table; Query. Second table OK when.
मुलाखत card: Single-table काय? · PNG download करा · Card page उघडा
मुलाखत card: Adjacency lists. Relations. Edge items. Student-course.
मुलाखत card: Adjacency lists · PNG download करा · Card page उघडा
मुलाखत card: PutItem कुठे?. No dup. Link chapters. CRUD, CLI, SDK.
मुलाखत card: PutItem कुठे? · PNG download करा · Card page उघडा

अजून cards: Ravi Sir's Cards.

सराव Tasks

या scenario बद्दल

Maple Leaf Books हा टोरांटो मधला पुस्तक विक्री व्यवसाय आहे. Emily Tremblay त्यांचं IT व cloud काम पाहतात. त्यांचे पैसे CAD मध्ये मोजले जातात आणि AWS resources ca-central-1 Region मध्ये चालतात. खालच्या tasks मध्ये तुम्ही या lesson मध्ये शिकलेलं वापरून त्यांची खरी कामं करता. सगळी नावं, account IDs, IP addresses व numbers सरावासाठी काल्पनिक आहेत.

0 / 16

सोपं Access first

का: Order.

काय करायचं: Access first तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Single-table

का: Idea.

काय करायचं: Single-table तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Prefixes

का: Keys.

काय करायचं: Prefixes तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Adjacency

का: Edges.

काय करायचं: Adjacency तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं Access map

का: Sketch.

काय करायचं: patterns यादी.

कसं करायचं:
  1. Task मधल्या top-level keys पासून सुरू करा.
  2. Child keys 2 spaces ने indent करा (tabs नकोत).
  3. प्रत्येक property मध्ये task मधली value भरा.
  4. Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.

सोपं No joins

का: Model.

काय करायचं: No SQL joins तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

सोपं GSI optional

का: Index.

काय करायचं: GSI alternate तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Item collection

का: Def.

काय करायचं: Same PK तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Sort key

का: Range.

काय करायचं: SK range तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Not ER-only

का: Mindset.

काय करायचं: ER-only trap तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Second table

का: Pragmatism.

काय करायचं: Second table OK तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

मध्यम Key sketch

का: Keys.

काय करायचं: pk/sk.

कसं करायचं:
  1. Task मधल्या top-level keys पासून सुरू करा.
  2. Child keys 2 spaces ने indent करा (tabs नकोत).
  3. प्रत्येक property मध्ये task मधली value भरा.
  4. Check answer दाबा. Keys चा क्रम महत्त्वाचा नाही.

अवघड Link

का: No dup.

काय करायचं: Link not rewrite तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Paper

का: Process.

काय करायचं: Paper first तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Overloaded SK

का: Design.

काय करायचं: Overloaded SK तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.

अवघड Sample JSON

का: Hygiene.

काय करायचं: Sample JSON तर 1.

कसं करायचं:
  1. Task मधले numbers लिहून घ्या.
  2. कागदावर step by step काढा.
  3. Box मध्ये फक्त final उत्तर लिहा.
  4. Check answer दाबा.