DynamoDB là dịch vụ NoSQL database phổ biến nhất trên AWS — nhanh, scalable và fully managed. Tuy nhiên, thuật ngữ của DynamoDB khác khá nhiều so với SQL truyền thống. Nếu bạn chuyển từ MySQL/PostgreSQL sang DynamoDB, bài này sẽ giúp bạn làm quen nhanh với “ngôn ngữ” mới.


🔹 Cấu trúc dữ liệu cơ bản

EnglishIPATiếng ViệtExample
table/ˈteɪbəl/bảng dữ liệuCreate a DynamoDB table to store user profiles.
item/ˈaɪtəm/bản ghi, mục dữ liệuEach item in the table represents a single order.
attribute/ˈætrɪbjuːt/thuộc tính, trường dữ liệuThe “email” attribute is required for every user item.

🔹 Keys & Indexes

EnglishIPATiếng ViệtExample
partition key/pɑːrˈtɪʃən kiː/khóa phân vùngUse “userId” as the partition key for even data distribution.
sort key/sɔːrt kiː/khóa sắp xếpAdd a timestamp as the sort key to query orders by date.
GSI (Global Secondary Index)/dʒiː ɛs aɪ/chỉ mục phụ toàn cụcCreate a GSI on the email field to query users by email.
LSI (Local Secondary Index)/ɛl ɛs aɪ/chỉ mục phụ cục bộAn LSI lets you query with a different sort key on the same partition.

🔹 Hiệu năng & cấu hình

EnglishIPATiếng ViệtExample
throughput/ˈθruːpʊt/thông lượngIncrease the read throughput to handle peak traffic.
on-demand/ɒn dɪˈmɑːnd/theo nhu cầuSwitch to on-demand mode so you don’t have to manage capacity manually.
TTL (Time to Live)/tiː tiː ɛl/thời gian sống của bản ghiSet TTL to automatically delete expired session records.
stream/striːm/luồng sự kiện thay đổiEnable DynamoDB streams to trigger a Lambda function on every update.

🔹 Truy vấn dữ liệu

EnglishIPATiếng ViệtExample
query/ˈkwɪəri/truy vấn (theo key)Use query to fetch all orders for a specific user.
scan/skæn/quét toàn bộ bảngAvoid scan on large tables — it reads every single item.
projection/prəˈdʒɛkʃən/chọn thuộc tính trả vềUse a projection expression to return only the name and email fields.
conditional expression/kənˈdɪʃənəl ɪkˈsprɛʃən/biểu thức điều kiệnAdd a conditional expression to update only if the item version matches.

💡 Mẹo ghi nhớ

  • Partition key = “chìa khóa phân loại” — DynamoDB dùng nó để phân tán dữ liệu vào các partition khác nhau.
  • Query vs Scan: Query giống tìm sách theo mục lục (nhanh), Scan giống đọc hết cả thư viện (chậm, tốn tiền).
  • GSI = “Global” vì nó query được across toàn bộ table, còn LSI = “Local” chỉ trong cùng partition.

📝 Bài tập

Điền từ thích hợp vào chỗ trống:

  1. Each record in a DynamoDB table is called an ___.
  2. The ___ determines how DynamoDB distributes data across partitions.
  3. Use ___ instead of scan to efficiently retrieve data by key.
  4. Set ___ on session items so they are automatically deleted after expiry.
  5. Create a ___ if you need to query the table by a non-primary-key field.
✅ Đáp án
  1. item — Mỗi bản ghi trong DynamoDB table được gọi là item
  2. partition key — Khóa phân vùng quyết định cách dữ liệu được phân tán
  3. query — Query truy vấn theo key, hiệu quả hơn scan rất nhiều
  4. TTL — Time to Live tự động xóa bản ghi hết hạn
  5. GSI — Global Secondary Index cho phép truy vấn theo field không phải primary key

Tổng kết

DynamoDB có hệ thuật ngữ riêng khác biệt so với SQL database truyền thống. Hiểu rõ partition key, GSI, và sự khác biệt giữa queryscan là chìa khóa để thiết kế bảng hiệu quả và tiết kiệm chi phí. Hãy bắt đầu với on-demand mode để thử nghiệm trước khi optimize throughput nhé! 💪


📚 Bài viết liên quan


🎯 Kết luận

Hy vọng bài viết giúp bạn tự tin hơn khi sử dụng tiếng Anh trong công việc IT. Hãy bookmark lại để tra cứu khi cần nhé!

👉 Xem thêm bài viết | 📱 App IELTS 6.0