Ngân hàng đề — AWS Certified Data Engineer Associate

Tìm thấy 867 câu.

Câu 751
A transportation company wants to track vehicle movements by capturing geolocation records. The records are 10 bytes in size. The company receives up to 10.000 records every second. Data transmission delays of a few minutes are acceptable because of unreliable network conditions.

The transportation company wants to use Amazon Kinesis Data Streams to ingest the geolocation data. The company needs a reliable mechanism to send data to Kinesis Data Streams. The company needs to maximize the throughput efficiency of the Kinesis shards.

Which solution will meet these requirements in the MOST operationally efficient way?
  1. A Kinesis Agent
  2. B Kinesis Producer Library (KPL)
  3. C Amazon Kinesis Data Firehose
  4. D Kinesis SDK
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi mô tả một tình huống thực tế của công ty vận tải:
Họ cần theo dõi vị trí địa lý (geolocation) của xe bằng cách thu thập records nhỏ (chỉ 10 bytes/record), với lưu lượng cao lên đến 10.000 records/giây (tương đương ~100 KB/s). Mạng không ổn định nên chấp nhận độ trễ vài phút.
Yêu cầu chính:

  • Sử dụng Amazon Kinesis Data Streams để ingest dữ liệu thời gian thực.
  • Cần cơ chế đáng tin cậy (reliable) để gửi dữ liệu vào Streams.
  • Tối ưu hóa throughput efficiency của shards (mỗi shard Kinesis Data Streams hỗ trợ tối đa 1 MB/s ingress và 1.000 PutRecord calls/sec theo tài liệu AWS cập nhật 2024-2026).

🛠️ Thách thức cốt lõi: Records rất nhỏ, số lượng lớn → cần batching (gom nhiều records vào một lời gọi) để tránh lãng phí throughput shard (vì PutRecord đơn lẻ sẽ kém hiệu quả). Giải pháp phải operationally efficient nhất (dễ vận hành, tự động retry, multi-threaded).

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Kinesis Producer Library (KPL)

Lý do chi tiết:
KPL là thư viện Java/C++/Node.js/Python chuyên dụng cho producers gửi dữ liệu vào Kinesis Data Streams. Nó tối ưu hóa throughput shard bằng cách:

  • Tự động aggregate (gom) nhiều records nhỏ (10 bytes) vào batch PutRecords (lên đến 500 records/lần gọi), giảm số lượng API calls từ 10.000 calls/sec xuống chỉ ~20 calls/sec.
  • Multi-threaded và configurable (có thể scale threads để xử lý 10k records/sec dễ dàng).
  • Reliable với retry logic, buffering local (lưu tạm dữ liệu nếu mạng kém, chấp nhận delay vài phút).
  • Hiệu quả nhất cho shards: Tiết kiệm PutRecord calls (shard limit 1.000 calls/sec), đạt gần 1 MB/s ingress mà không lãng phí.
    Theo AWS best practices 2026, KPL là lựa chọn MOST operationally efficient cho high-volume small payloads như geolocation data.

📋 Giải thích tất cả các phương án (đúng/sai)

Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên yêu cầu reliable mechanism + maximize shard throughput efficiency:

  • ❌ Kinesis Agent
    Sai vì: Kinesis Agent chỉ dành cho streaming log files từ server (như /var/log), không hỗ trợ high-throughput real-time data như 10.000 records/giây từ devices. Nó dùng PutRecord đơn lẻ, không batch → lãng phí shard throughput. Không reliable cho unreliable networks (không có advanced retry/buffering). Phù hợp cho logs thấp hơn, không phải geolocation streaming.

  • ✅ Kinesis Producer Library (KPL)
    Đúng vì: Như đã giải thích ở trên, KPL chính xác match requirements: Aggregate records để maximize shard efficiency, reliable với retry và local buffering (chấp nhận delay mạng), dễ integrate vào apps producers. AWS khuyến nghị cho workloads như IoT/geolocation cao tải.

  • ❌ Amazon Kinesis Data Firehose
    Sai vì: Firehose là fully-managed service để transform và deliver data đến S3/Redshift/etc, không phải producer trực tiếp cho Data Streams (dù có thể put vào Streams nhưng overhead cao). Không kiểm soát batching chi tiết, kém efficient cho pure ingestion vào Streams. Không maximize shard throughput vì thêm layer transformation không cần thiết ở đây.

  • ❌ Kinesis SDK
    Sai vì: Kinesis SDK (AWS SDK cho Java/Python/etc) chỉ cung cấp low-level APIs như PutRecord (1 record/lần gọi) → với 10.000 records/sec cần 10.000 calls/sec, vượt shard limit (1.000 calls/sec) và lãng phí bandwidth (records nhỏ). Phải tự implement batching/retry → không operationally efficient so với KPL (KPL build on SDK nhưng optimized).

📘 Tài liệu tham khảo (AWS cập nhật mới nhất 2024-2026)

  • AWS Kinesis Data Streams Developer Guide: Monitoring the Kinesis Producer Library (KPL) – Chi tiết shard limits và KPL optimization.
  • Best Practices for Producers: Developers Guide - KPL – Khuyến nghị KPL cho high-throughput small records.
  • Kinesis Agent docs: AWS docs – Giới hạn chỉ logs.
  • So sánh KPL vs SDK: AWS Well-Architected Framework - Stream Data Processing (Lens 2026 update).

🛠️ Khuyến nghị triển khai: Integrate KPL vào producer apps (e.g., vehicle telematics), set MaxBufferedTime: 5000ms để batch, monitor với CloudWatch Metrics (PutRecord.Success). Scale shards dựa trên 100 KB/s (~1 shard đủ)!

Câu 752
An investment company needs to manage and extract insights from a volume of semi-structured data that grows continuously.

A data engineer needs to deduplicate the semi-structured data, remove records that are duplicates, and remove common misspellings of duplicates.

Which solution will meet these requirements with the LEAST operational overhead?
  1. A Use the FindMatches feature of AWS Glue to remove duplicate records.
  2. B Use non-Windows functions in Amazon Athena to remove duplicate records.
  3. C Use Amazon Neptune ML and an Apache Gremlin script to remove duplicate records.
  4. D Use the global tables feature of Amazon DynamoDB to prevent duplicate data.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào một công ty đầu tư cần quản lý và trích xuất insights từ lượng dữ liệu semi-structured (dữ liệu không cấu trúc hoàn toàn, như JSON, CSV với biến đổi) tăng liên tục. Data engineer phải thực hiện deduplicate (loại bỏ trùng lặp), xóa các bản ghi trùng lặp, và đặc biệt xử lý các lỗi chính tả phổ biến của trùng lặp (như "Apel" và "Apple"). Yêu cầu chính là giải pháp có LEAST operational overhead (ít công vận hành nhất, tức tự động hóa cao, ít code thủ công, dễ scale).

📘 Dẫn nguồn: AWS Well-Architected Framework (Data Analytics Lens, cập nhật 2024-2026) nhấn mạnh sử dụng ML-native tools như AWS Glue cho data cleaning semi-structured với low overhead. Tài liệu chính thức: AWS Glue FindMatches.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use the FindMatches feature of AWS Glue to remove duplicate records.

🛠️ Lý do chi tiết:

  • AWS Glue FindMatches là tính năng ML-based machine learning chuyên dụng để tự động phát hiện và loại bỏ duplicates trong dữ liệu semi-structured, hỗ trợ fuzzy matching (khớp mờ) xử lý lỗi chính tả, biến thể (misspellings) mà không cần code phức tạp.
  • Least operational overhead: Chỉ cần cấu hình job Glue ETL (Extract-Transform-Load), tích hợp trực tiếp với S3/Data Catalog, scale serverless, không cần quản lý infra hay viết script thủ công. Phù hợp dữ liệu tăng liên tục, chạy batch hoặc streaming.
  • Cập nhật 2026: Glue 4.0+ hỗ trợ FindMatches với accuracy >95% cho semi-structured, tích hợp SageMaker cho custom model nếu cần.
  • Ưu điểm: Tích hợp liền mạch với AWS ecosystem (Athena, EMR, Lake Formation), chi phí pay-per-use.

📋 Giải thích tất cả các phương án (đúng/sai)

Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá dựa trên tính phù hợp, overhead và khả năng xử lý misspellings.

  • Use the FindMatches feature of AWS Glue to remove duplicate records.
    ✅ Đúng: Như giải thích trên, đây là giải pháp tối ưu nhất với ML tự động, fuzzy matching cho misspellings, zero/low-code, serverless. Overhead thấp nhất cho dữ liệu semi-structured lớn.

  • Use non-Windows functions in Amazon Athena to remove duplicate records.
    ❌ Sai: "Non-window functions" (có lẽ ám chỉ non-window như ROW_NUMBER(), RANK() trong SQL) chỉ dedup exact matches qua query, không xử lý misspellings/fuzzy (cần UDF phức tạp hoặc ML riêng). Athena là query engine serverless nhưng yêu cầu viết SQL thủ công lặp lại, overhead cao cho dữ liệu tăng (query chậm với TB-scale), không tự động hóa tốt như Glue. Phù hợp query-once, không phải continuous processing.

  • Use Amazon Neptune ML and an Apache Gremlin script to remove duplicate records.
    ❌ Sai: Neptune là graph database (Neptune ML cho node prediction), Gremlin script dùng query graph không phù hợp semi-structured dedup (cần model graph trước, overhead cao build schema). Không hỗ trợ fuzzy misspellings native, yêu cầu code Gremlin phức tạp + training ML, scale kém cho non-graph data, overhead vận hành rất cao (provision instances).

  • Use the global tables feature of Amazon DynamoDB to prevent duplicate records.
    ❌ Sai: Global Tables chỉ multi-region replication để high availability, không deduplicate hay xử lý misspellings (DynamoDB key-based, exact match only). Overhead cao nếu ingest data vào DynamoDB (partition limit 40KB/item), không dành cho semi-structured analytics/batch processing lớn.

🏆 Kết luận & Lời khuyên DevOps

Giải pháp Glue FindMatches là best practice cho data pipeline semi-structured theo AWS re:Invent 2025 (Data/ML track). Để implement: Tạo Glue Job > Add FindMatches transform > Output to S3. Test với sample data để tune accuracy.

📘 Tài liệu tham khảo thêm:

Nếu cần demo code Glue job, hãy hỏi thêm! 🚀

Câu 753 Chọn nhiều đáp án
A company is building an inventory management system and an inventory reordering system to automatically reorder products. Both systems use Amazon Kinesis Data Streams. The inventory management system uses the Amazon Kinesis Producer Library (KPL) to publish data to a stream. The inventory reordering system uses the Amazon Kinesis Client Library (KCL) to consume data from the stream. The company configures the stream to scale up and down as needed.

Before the company deploys the systems to production, the company discovers that the inventory reordering system received duplicated data.

Which factors could have caused the reordering system to receive duplicated data? (Choose two.)
  1. A The producer experienced network-related timeouts.
  2. B The stream’s value for the IteratorAgeMilliseconds metric was too high.
  3. C There was a change in the number of shards, record processors, or both.
  4. D The AggregationEnabled configuration property was set to true.
  5. E The max_records configuration property was set to a number that was too high.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi mô tả một công ty đang xây dựng hệ thống quản lý hàng tồn kho (inventory management system) và hệ thống đặt hàng tự động (inventory reordering system). Cả hai hệ thống sử dụng Amazon Kinesis Data Streams để xử lý dữ liệu thời gian thực:

  • Hệ thống quản lý hàng tồn kho sử dụng Amazon Kinesis Producer Library (KPL) để publish (gửi) dữ liệu vào stream.
  • Hệ thống đặt hàng sử dụng Amazon Kinesis Client Library (KCL) để consume (tiêu thụ) dữ liệu từ stream.
  • Stream được cấu hình scale up/down tự động theo nhu cầu (sử dụng shard auto-scaling).

Trước khi triển khai production, hệ thống đặt hàng phát hiện dữ liệu bị duplicate (trùng lặp). Câu hỏi yêu cầu chọn TWO yếu tố có thể gây ra tình trạng này ở hệ thống reordering.

Mục tiêu chính: Xác định nguyên nhân gây duplicated data trong Kinesis, tập trung vào cơ chế retry của KPL và quản lý checkpoint/processor của KCL. Kinesis Data Streams không đảm bảo exactly-once semantics mặc định (at-least-once delivery), nên duplicates có thể xảy ra do retry hoặc reprocessing. (Kiến thức cập nhật AWS 2024-2026: Kinesis hỗ trợ enhanced fan-out và checkpointing cải tiến, nhưng cơ bản vẫn vậy).

✅ Đáp án đúng (Chọn TWO)

Hai đáp án đúng là:

  • The producer experienced network-related timeouts.
  • There was a change in the number of shards, record processors, or both.

Lý do lựa chọn:

  • KPL và KCL được thiết kế để xử lý at-least-once delivery, nghĩa là dữ liệu có thể được gửi/nhận nhiều lần để tránh mất mát.
  • Network timeouts ở producer kích hoạt retry mechanism của KPL, dẫn đến publish duplicate records nếu không có idempotency.
  • Thay đổi shards hoặc record processors (do scale stream hoặc restart app) làm gián đoạn checkpointing của KCL, buộc reprocess records cũ → duplicates. 🛠️ Đây là các nguyên nhân phổ biến nhất theo best practices AWS.

📝 Giải thích chi tiết từng phương án

Dưới đây là phân tích tất cả 5 lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh dấu ✅ (đúng) hoặc ❌ (sai), kèm giải thích rõ ràng:

  • ✅ The producer experienced network-related timeouts.
    🧩 Đúng: KPL có cơ chế retry tự động khi gặp network timeouts (ví dụ: HTTP 5xx errors). Nếu producer không nhận ACK kịp thời, nó sẽ resend record với cùng sequence number, nhưng consumer (KCL) vẫn xử lý như record mới → duplicated data. Đây là hành vi at-least-once chuẩn của KPL để tránh data loss.

  • ❌ The stream’s value for the IteratorAgeMilliseconds metric was too high.
    🧩 Sai: Metric IteratorAgeMilliseconds đo consumer lag (thời gian từ khi record được publish đến khi consume). Giá trị cao chỉ báo hiệu backlog hoặc scale issue, nhưng không trực tiếp gây duplicates. Nó cảnh báo performance, không phải nguyên nhân retry/reprocess.

  • ✅ There was a change in the number of shards, record processors, or both.
    🧩 Đúng: KCL sử dụng RecordProcessor và checkpointing để track progress. Khi shards thay đổi (do auto-scaling) hoặc số processors thay đổi (app restart, instance fail), KCL phải reassign shards và reprocess từ checkpoint gần nhất → records được consume lại → duplicates. Đây là vấn đề phổ biến khi stream scale dynamically.

  • ❌ The AggregationEnabled configuration property was set to true.
    🧩 Sai: AggregationEnabled=true kích hoạt Kinesis Aggregated Records (batch nhiều records thành một để tiết kiệm throughput). KCL (với deaggregation) sẽ unpack đúng mà không gây duplicates. Nó chỉ tối ưu chi phí, không ảnh hưởng delivery semantics.

  • ❌ The max_records configuration property was set to a number that was too high.
    🧩 Sai: max_records (trong KCL GetRecords config) giới hạn số records max mỗi lần poll (mặc định 10000). Giá trị cao chỉ tăng batch size, cải thiện throughput nhưng không gây duplicates. Nó liên quan performance tuning, không phải retry/checkpoint.

📘 Tài liệu tham khảo (AWS cập nhật 2024-2026)

Hy vọng phân tích này giúp bạn nắm vững! 🚀 Nếu cần thêm ví dụ code KPL/KCL, hãy hỏi nhé!

Câu 754
An ecommerce company operates a complex order fulfilment process that spans several operational systems hosted in AWS. Each of the operational systems has a Java Database
Connectivity (JDBC)-compliant relational database where the latest processing state is captured.

The company needs to give an operations team the ability to track orders on an hourly basis across the entire fulfillment process.

Which solution will meet these requirements with the LEAST development overhead?
  1. A Use AWS Glue to build ingestion pipelines from the operational systems into Amazon Redshift Build dashboards in Amazon QuickSight that track the orders.
  2. B Use AWS Glue to build ingestion pipelines from the operational systems into Amazon DynamoDBuild dashboards in Amazon QuickSight that track the orders.
  3. C Use AWS Database Migration Service (AWS DMS) to capture changed records in the operational systems. Publish the changes to an Amazon DynamoDB table in a different AWS region from the source database. Build Grafana dashboards that track the orders.
  4. D Use AWS Database Migration Service (AWS DMS) to capture changed records in the operational systems. Publish the changes to an Amazon DynamoDB table in a different AWS region from the source database. Build Amazon QuickSight dashboards that track the orders.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi mô tả một công ty thương mại điện tử (ecommerce) đang vận hành quy trình xử lý đơn hàng (order fulfilment) phức tạp, trải rộng qua nhiều hệ thống hoạt động (operational systems) trên AWS. Mỗi hệ thống này đều có cơ sở dữ liệu quan hệ (relational database) tuân thủ JDBC, nơi lưu trữ trạng thái xử lý mới nhất của các đơn hàng.

Yêu cầu chính:

  • Cho phép đội ngũ vận hành (operations team) theo dõi (track) đơn hàng hàng giờ qua toàn bộ quy trình fulfillment.
  • Giải pháp phải có ít overhead phát triển nhất (LEAST development overhead), nghĩa là ưu tiên các dịch vụ AWS managed, low-code/no-code, dễ tích hợp và ít phải code custom.

Thách thức chính:

  • Dữ liệu phân tán qua nhiều DB relational → Cần tổng hợp (ingest) dữ liệu từ nhiều nguồn.
  • Theo dõi hourly → Phù hợp với batch processing định kỳ (ETL/ELT), không cần real-time cao.
  • Analytics phức tạp (track across entire process) → Cần data warehouse hỗ trợ query JOIN, aggregate lớn.
    📘 Kiến thức AWS cập nhật 2026: AWS Glue (ETL serverless), Amazon Redshift (data warehouse columnar), QuickSight (BI serverless) là combo chuẩn cho analytics hourly với low overhead. DMS dùng cho CDC real-time/migration, nhưng phức tạp hơn cho batch analytics.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use AWS Glue to build ingestion pipelines from the operational systems into Amazon Redshift. Build dashboards in Amazon QuickSight that track the orders.

Lý do chi tiết 🛠️:

  • AWS Glue là dịch vụ ETL serverless, hỗ trợ crawl JDBC DBs tự động tạo schema, build pipelines ingestion batch (hourly jobs) từ nhiều nguồn relational vào Redshift với crawl-and-catalog zero-code. Ít overhead nhất vì visual ETL jobs, no server management.
  • Amazon Redshift là data warehouse columnar tối ưu cho analytics phức tạp (JOIN tables từ nhiều systems), query SQL nhanh trên petabyte data, hỗ trợ hourly materialized views/concurrency scaling.
  • Amazon QuickSight tích hợp native với Redshift (SPICE engine), build dashboards trực quan track orders real-time/hourly, ML insights tự động, zero dev overhead (drag-drop).
  • Combo này least overhead: Standard AWS pattern cho operational analytics, không cần custom code, multi-region resilient. Theo AWS Well-Architected Framework (Reliability & Operational Excellence pillars).

Tài liệu tham khảo:

🔍 Phân tích tất cả các phương án (đúng/sai)

  • Phương án đúng ✅:
    Use AWS Glue to build ingestion pipelines from the operational systems into Amazon Redshift. Build dashboards in Amazon QuickSight that track the orders.
    Giải thích: Như đã phân tích ở trên, đây là giải pháp tối ưu với ETL batch hourly low-code qua Glue, data warehouse analytics Redshift, và BI native QuickSight. Hoàn hảo cho tracking cross-systems mà không cần dev nhiều.

  • Phương án sai ❌:
    Use AWS Glue to build ingestion pipelines from the operational systems into Amazon DynamoDB. Build dashboards in Amazon QuickSight that track the orders.
    Giải thích: Glue hỗ trợ ingest vào DynamoDB, nhưng DynamoDB là NoSQL key-value không phù hợp analytics phức tạp (khó JOIN tables từ nhiều sources, query aggregate kém hiệu suất). Overhead cao hơn vì cần custom partitioning/GSI cho hourly queries. QuickSight hỗ trợ DynamoDB nhưng kém Redshift cho data warehouse workloads.

  • Phương án sai ❌:
    Use AWS Database Migration Service (AWS DMS) to capture changed records in the operational systems. Publish the changes to an Amazon DynamoDB table in a different AWS region from the source database. Build Grafana dashboards that track the orders.
    Giải thích: DMS tốt cho CDC real-time/migration, nhưng overhead cao (cần setup tasks, endpoints, replication instances; không low-code như Glue). DynamoDB ở different region gây latency/cost không cần thiết (không yêu cầu multi-region). Grafana không phải AWS managed BI, cần tự host/integrate Prometheus, dev overhead lớn, kém QuickSight cho dashboards hourly.

  • Phương án sai ❌:
    Use AWS Database Migration Service (AWS DMS) to capture changed records in the operational systems. Publish the changes to an Amazon DynamoDB table in a different AWS region from the source database. Build Amazon QuickSight dashboards that track the orders.
    Giải thích: Tương tự phương án trên, DMS + DynamoDB different region overhead cao (setup phức tạp, cost replication cross-region). DynamoDB kém cho complex analytics hourly (single-table design limit JOINs). QuickSight tốt nhưng kết hợp DynamoDB kém hiệu quả so với Redshift cho operational tracking multi-source.

Kết luận 🎯: Giải pháp đúng tận dụng data lakehouse pattern AWS (Glue → Redshift → QuickSight), đảm bảo scalability, cost-effective, và least dev effort cho DOP workloads!

Câu 755 Chọn nhiều đáp án
A data engineer needs to use Amazon Neptune to develop graph applications.

Which programming languages should the engineer use to develop the graph applications? (Choose two.)
  1. A Gremlin
  2. B SQL
  3. C ANSI SQL
  4. D SPARQL
  5. E Spark SQL
Xem giải thích

🧩 Phân tích chi tiết câu hỏi

Câu hỏi tập trung vào Amazon Neptune, một dịch vụ cơ sở dữ liệu đồ thị (graph database) hoàn toàn được quản lý trên AWS, được thiết kế để lưu trữ và truy vấn dữ liệu đồ thị một cách hiệu quả. Cụ thể, một data engineer cần phát triển các ứng dụng đồ thị (graph applications) sử dụng Neptune. Câu hỏi yêu cầu chọn hai ngôn ngữ lập trình/query phù hợp nhất để phát triển các ứng dụng này.

Amazon Neptune hỗ trợ hai mô hình dữ liệu chính:

  • Property Graph model: Sử dụng ngôn ngữ truy vấn Gremlin (dựa trên Apache TinkerPop).
  • RDF (Resource Description Framework) model: Sử dụng ngôn ngữ truy vấn SPARQL.

Neptune không hỗ trợ SQL trực tiếp vì nó không phải là cơ sở dữ liệu quan hệ (relational database), mà tập trung vào dữ liệu đồ thị với các mối quan hệ phức tạp (nodes, edges, properties). Điều này giúp xử lý các use case như khuyến nghị, phát hiện gian lận, mạng xã hội... Kiến thức cập nhật đến năm 2026: Neptune vẫn giữ nguyên hỗ trợ Gremlin và SPARQL làm các ngôn ngữ chính thức, với các cải tiến về hiệu suất và tích hợp (như Neptune Analytics với Gremlin/SPARQL streaming).

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Gremlin và SPARQL.
🛠️ Lý do:

  • Neptune được thiết kế dành riêng cho graph applications, và hai ngôn ngữ chuẩn hóa duy nhất mà nó hỗ trợ là Gremlin (cho Property Graphs) và SPARQL (cho RDF graphs).
  • Sử dụng chúng cho phép data engineer viết query để traverse graph, thêm/sửa/xóa nodes/edges một cách tối ưu. Đây là lựa chọn chính thức từ AWS, đảm bảo tính tương thích và hiệu suất cao nhất.

📋 Giải thích tất cả các phương án (đúng và sai)

Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh:

  • ✅ Gremlin
    Phương án ĐÚNG. Gremlin là ngôn ngữ truy vấn chuẩn cho Property Graph model trong Neptune. Nó cho phép thực hiện các hoạt động phức tạp như traversal (duyệt đồ thị), pattern matching. Neptune hỗ trợ Gremlin qua endpoint WebSocket (port 8182), và là lựa chọn phổ biến cho các ứng dụng graph thực tế.

  • ❌ SQL
    Phương án SAI. SQL là ngôn ngữ cho cơ sở dữ liệu quan hệ (như Amazon RDS hoặc Aurora), không phù hợp với graph data. Neptune không hỗ trợ SQL native vì graph yêu cầu query traversal thay vì join bảng.

  • ❌ ANSI SQL
    Phương án SAI. ANSI SQL là tiêu chuẩn SQL quốc tế cho relational databases. Neptune không implement ANSI SQL vì nó không phải RDBMS; sử dụng SQL sẽ không truy vấn được graph structures hiệu quả.

  • ✅ SPARQL
    Phương án ĐÚNG. SPARQL là ngôn ngữ truy vấn chuẩn cho RDF graphs trong Neptune. Nó hỗ trợ query semantic data qua endpoint HTTP (port 8180), lý tưởng cho knowledge graphs, ontologies, và linked data.

  • ❌ Spark SQL
    Phương án SAI. Spark SQL là extension của SQL cho Apache Spark (big data processing), dùng trên Amazon EMR hoặc Glue. Neptune không tích hợp Spark SQL trực tiếp cho graph queries; chỉ hỗ trợ Gremlin/SPARQL.

📘 Tài liệu tham khảo

Hy vọng phân tích này giúp bạn ôn thi AWS hiệu quả! 🚀 Nếu cần thêm ví dụ code, hãy hỏi nhé!

Câu 756
A mobile gaming company wants to capture data from its gaming app. The company wants to make the data available to three internal consumers of the data. The data records are approximately 20 KB in size.

The company wants to achieve optimal throughput from each device that runs the gaming app. Additionally, the company wants to develop an application to process data streams. The stream-processing application must have dedicated throughput for each internal consumer.

Which solution will meet these requirements?
  1. A Configure the mobile app to call the PutRecords API operation to send data to Amazon Kinesis Data Streams. Use the enhanced fan-out feature with a stream for each internal consumer.
  2. B Configure the mobile app to call the PutRecordBatch API operation to send data to Amazon Kinesis Data Firehose. Submit an AWS Support case to turn on dedicated throughput for the company’s AWS account. Allow each internal consumer to access the stream.
  3. C Configure the mobile app to use the Amazon Kinesis Producer Library (KPL) to send data to Amazon Kinesis Data Firehose. Use the enhanced fan-out feature with a stream for each internal consumer.
  4. D Configure the mobile app to call the PutRecords API operation to send data to Amazon Kinesis Data Streams. Host the stream-processing application for each internal consumer on Amazon EC2 instances. Configure auto scaling for the EC2 instances.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi xoay quanh một công ty game di động muốn thu thập dữ liệu từ ứng dụng game (kích thước record khoảng 20 KB mỗi bản ghi). Dữ liệu cần được cung cấp cho 3 người tiêu dùng nội bộ (internal consumers). Các yêu cầu chính bao gồm:

  • Tối ưu hóa throughput từ mỗi thiết bị chạy app (tức là producers như mobile devices cần gửi dữ liệu nhanh, hiệu quả cao).
  • Xây dựng ứng dụng xử lý stream với dedicated throughput riêng biệt cho từng internal consumer (mỗi consumer có băng thông riêng, không chia sẻ, để tránh bottleneck).

Giải pháp phải sử dụng dịch vụ AWS phù hợp cho streaming dữ liệu real-time, hỗ trợ batching từ producers và fan-out dedicated cho consumers. Kinesis Data Streams là dịch vụ lý tưởng vì hỗ trợ shards cho throughput cao, PutRecords cho batch efficient, và enhanced fan-out (tính năng mới từ 2019, cập nhật đến 2026 vẫn là chuẩn) cho phép consumers đọc dữ liệu với throughput riêng (lên đến 2 MB/s/shard/consumer, không ảnh hưởng lẫn nhau).

✅ Đáp án đúng

Configure the mobile app to call the PutRecords API operation to send data to Amazon Kinesis Data Streams. Use the enhanced fan-out feature with a stream for each internal consumer.

Lý do chọn đáp án này 🎯:

  • PutRecords API của Kinesis Data Streams cho phép gửi batch lên đến 500 records (tối ưu throughput từ mobile devices, mỗi record 20KB phù hợp giới hạn 5MB/request).
  • Enhanced fan-out cung cấp dedicated throughput (2MB/s/shard/consumer) cho stream-processing apps, đăng ký riêng cho từng consumer mà không chia sẻ với standard consumers. Sử dụng một stream chính và consumer riêng cho mỗi internal consumer (có thể scale shards nếu cần). Điều này đáp ứng hoàn hảo real-time processing với isolation throughput.
  • Kiến thức cập nhật 2026: Enhanced fan-out vẫn là best practice cho multi-consumer scenarios (hỗ trợ lên đến 20 consumers/stream với Subscriber API).

📋 Phân tích tất cả các phương án

  • Configure the mobile app to call the PutRecords API operation to send data to Amazon Kinesis Data Streams. Use the enhanced fan-out feature with a stream for each internal consumer.
    ✅ Đúng 🏆: Như giải thích trên, kết hợp PutRecords cho producer throughput cao + enhanced fan-out cho dedicated consumer throughput. Hoàn hảo match requirements.

  • Configure the mobile app to call the PutRecordBatch API operation to send data to Amazon Kinesis Data Firehose. Submit an AWS Support case to turn on dedicated throughput for the company’s AWS account. Allow each internal consumer to access the stream.
    ❌ Sai 🚫: Kinesis Data Firehose dùng cho delivery/buffering đến destinations (như S3/Lambda), không phải real-time stream processing với multiple consumers. PutRecordBatch tồn tại nhưng Firehose không hỗ trợ enhanced fan-out hoặc dedicated throughput per consumer (không có khái niệm consumers như Data Streams). AWS Support không enable "dedicated throughput" cho Firehose theo cách này – Firehose scale tự động nhưng shared.

  • Configure the mobile app to use the Amazon Kinesis Producer Library (KPL) to send data to Amazon Kinesis Data Firehose. Use the enhanced fan-out feature with a stream for each internal consumer.
    ❌ Sai 🔒: KPL hỗ trợ Firehose nhưng Firehose không có enhanced fan-out (tính năng chỉ dành cho Data Streams). Firehose là delivery stream, không cho phép consumers đọc real-time với dedicated throughput riêng lẻ. Sử dụng KPL chỉ giúp aggregation nhưng không giải quyết multi-consumer isolation.

  • Configure the mobile app to call the PutRecords API operation to send data to Amazon Kinesis Data Streams. Host the stream-processing application for each internal consumer on Amazon EC2 instances. Configure auto scaling for the EC2 instances.
    ❌ Sai ⚠️: PutRecords đúng cho producers, nhưng EC2 với auto scaling dùng standard consumer model (chia sẻ throughput shards, max 2MB/s total per shard cho tất cả consumers). Không có dedicated throughput như enhanced fan-out (standard polling gây bottleneck khi multi-consumer). EC2 auto scaling chỉ scale instances, không isolate bandwidth per consumer.

📘 Tài liệu tham khảo (AWS cập nhật 2026)

Giải pháp này đảm bảo high-throughput, low-latency với chi phí tối ưu! 🚀 Nếu cần demo code hoặc architecture diagram, hãy hỏi thêm nhé! 🛠️

Câu 757 Chọn nhiều đáp án
A retail company uses an Amazon Redshift data warehouse and an Amazon S3 bucket. The company ingests retail order data into the S3 bucket every day.

The company stores all order data at a single path within the S3 bucket. The data has more than 100 columns. The company ingests the order data from a third-party application that generates more than 30 files in CSV format every day. Each CSV file is between 50 and 70 MB in size.

The company uses Amazon Redshift Spectrum to run queries that select sets of columns. Users aggregate metrics based on daily orders. Recently, users have reported that the performance of the queries has degraded. A data engineer must resolve the performance issues for the queries.

Which combination of steps will meet this requirement with LEAST developmental effort? (Choose two.)
  1. A Configure the third-party application to create the files in a columnar format.
  2. B Develop an AWS Glue ETL job to convert the multiple daily CSV files to one file for each day.
  3. C Partition the order data in the S3 bucket based on order date.
  4. D Configure the third-party application to create the files in JSON format.
  5. E Load the JSON data into the Amazon Redshift table in a SUPER type column.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi xoay quanh việc tối ưu hóa hiệu suất truy vấn Amazon Redshift Spectrum trên dữ liệu lưu trữ trong Amazon S3.

  • Bối cảnh: Một công ty bán lẻ sử dụng Amazon Redshift data warehouse kết nối với S3 bucket. Dữ liệu đơn hàng (retail order data) được ingest hàng ngày từ ứng dụng bên thứ ba vào S3 dưới dạng >30 files CSV, mỗi file 50-70 MB, tổng >100 cột. Tất cả dữ liệu nằm ở một path duy nhất trong S3.
  • Vấn đề: Query Redshift Spectrum chọn tập hợp các cột cụ thể và tổng hợp metrics theo ngày bị chậm dần (performance degraded).
  • Yêu cầu: Chọn kết hợp 2 bước để giải quyết với LEAST developmental effort (ít nỗ lực phát triển nhất). Tập trung vào best practices cho Redshift Spectrum như partition pruning (loại bỏ partition không cần) và columnar storage để giảm scan dữ liệu không cần thiết.

📘 Nguồn tham khảo:

✅ Đáp án đúng (Chọn TWO)

Hai lựa chọn đúng là:

  1. Configure the third-party application to create the files in a columnar format.
  2. Partition the order data in the S3 bucket based on order date.

Lý do lựa chọn 🛠️:

  • Với dữ liệu CSV row-major (dựa trên hàng), Redshift Spectrum phải scan toàn bộ file ngay cả khi chỉ select vài cột → tốn I/O cao, đặc biệt với >100 cột và query aggregate theo ngày.
  • Columnar format (như Parquet/ORC) cho phép column pruning (chỉ đọc cột cần), compression tốt, giảm chi phí scan lên đến 75-90%.
  • Partition theo order date kích hoạt partition pruning, Redshift Spectrum chỉ scan partitions ngày cụ thể → giảm dữ liệu scan đáng kể cho query daily metrics.
  • Least effort: Partition dễ thực hiện (thay đổi ingest path hoặc dùng AWS Glue Partitioning), columnar chỉ cần config app third-party (ít code mới). Kết hợp hai bước này giải quyết root cause mà không cần ETL phức tạp.

📋 Giải thích tất cả các phương án

Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do chi tiết:

  • ✅ Configure the third-party application to create the files in a columnar format.
    Đúng 🏆: Chuyển sang columnar (Parquet/ORC) là best practice hàng đầu cho Redshift Spectrum với >100 cột và select subset columns. Giảm scan dữ liệu không cần, hỗ trợ predicate pushdown, compression (Snappy/Zlib). Ít effort nếu app third-party hỗ trợ export Parquet. Theo AWS benchmarks 2025, cải thiện performance 10x so với CSV.

  • ❌ Develop an AWS Glue ETL job to convert the multiple daily CSV files to one file for each day.
    Sai 🚫: Việc gộp >30 files CSV thành 1 file/ngày không giải quyết vấn đề cốt lõi (CSV vẫn row-based, scan toàn bộ). Thậm chí tăng effort (phát triển Glue job, schedule hàng ngày) và có thể làm chậm hơn nếu file quá lớn (>1GB khuyến cáo tránh cho Spectrum). Không tận dụng partition/column pruning.

  • ✅ Partition the order data in the S3 bucket based on order date.
    Đúng 🏆: Partition theo ngày (ví dụ: s3://bucket/orders/year=2026/month=01/day=15/) kích hoạt partition pruning tự động trong Redshift Spectrum. Query daily chỉ scan 1 partition thay vì toàn bộ dữ liệu → giảm scan 90%+. Ít effort nhất: Chỉ cần thay đổi ingest path hoặc dùng Glue Crawler auto-detect partitions (hỗ trợ Hive-style partitioning từ 2024).

  • ❌ Configure the third-party application to create the files in JSON format.
    Sai 🚫: JSON là semi-structured, row-based, tệ hơn CSV cho columnar queries (không hỗ trợ column pruning tốt, parse chậm). Redshift Spectrum hỗ trợ JSON nhưng performance kém với >100 fields, tăng CPU/memory. Không khuyến cáo cho structured data như orders.

  • ❌ Load the JSON data into the Amazon Redshift table in a SUPER type column.
    Sai 🚫: SUPER (tính năng Redshift 2023+) dành cho semi-structured/variable schema (như logs), không phù hợp dữ liệu structured CSV >100 cột cố định. Load vào Redshift cluster (không dùng Spectrum) tốn storage/compute, mất lợi ích S3 decoupling. Hơn nữa, câu hỏi tập trung Spectrum (query S3 trực tiếp), và JSON không được đề cập ở input gốc.

Kết luận 🎯: Kết hợp columnar + partitioning là giải pháp tối ưu, scalable nhất theo AWS Well-Architected Framework (Operational Excellence pillar, cập nhật 2026). Nếu implement, test với EXPLAIN query để verify pruning!

Câu 758
A company stores customer records in Amazon S3. The company must not delete or modify the customer record data for 7 years after each record is created. The root user also must not have the ability to delete or modify the data.

A data engineer wants to use S3 Object Lock to secure the data.

Which solution will meet these requirements?
  1. A Enable governance mode on the S3 bucket. Use a default retention period of 7 years.
  2. B Enable compliance mode on the S3 bucket. Use a default retention period of 7 years.
  3. C Place a legal hold on individual objects in the S3 bucket. Set the retention period to 7 years.
  4. D Set the retention period for individual objects in the S3 bucket to 7 years.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào tính năng S3 Object Lock của Amazon S3, được thiết kế để bảo vệ dữ liệu bằng cách khóa các object (đối tượng) không cho phép xóa hoặc sửa đổi trong một khoảng thời gian nhất định (retention period). 🛡️

Yêu cầu cụ thể của công ty:

  • Lưu trữ hồ sơ khách hàng trong S3.
  • Không được xóa hoặc sửa dữ liệu trong 7 năm kể từ khi mỗi bản ghi được tạo.
  • Ngay cả root user (tài khoản gốc) cũng không có quyền xóa hoặc sửa dữ liệu.
  • Data engineer muốn sử dụng S3 Object Lock để đáp ứng.

Bối cảnh AWS (cập nhật đến 2026):

  • S3 Object Lock chỉ hoạt động trên S3 bucket với phiên bản hóa (Versioning) được kích hoạt.
  • Có hai chế độ (mode): Governance và Compliance.
  • Default retention period áp dụng cho tất cả object mới upload vào bucket (không chỉ định retention riêng).
  • Tính năng này tuân thủ các quy định pháp lý như SEC Rule 17a-4(f), FINRA, giúp bảo vệ dữ liệu bất biến (immutable). 📘

Mục tiêu: Tìm giải pháp sử dụng Object Lock đảm bảo khóa dữ liệu 7 năm, không bypass được bởi root user.

✅ Đáp án đúng

Enable compliance mode on the S3 bucket. Use a default retention period of 7 years.

Lý do lựa chọn (chi tiết):

  • Compliance mode là chế độ nghiêm ngặt nhất: Không ai (kể cả root user) có thể xóa, sửa hoặc bypass retention period trước khi hết hạn (7 năm ở đây). Điều này đáp ứng hoàn hảo yêu cầu "root user cũng phải không có khả năng".
  • Default retention period của 7 năm sẽ tự động áp dụng cho mọi object mới upload vào bucket, đảm bảo tính nhất quán mà không cần cấu hình từng object riêng lẻ.
  • Quy trình triển khai: Kích hoạt Versioning → Kích hoạt Object Lock ở Compliance mode → Đặt default retention (WORM - Write Once Read Many) với Retain Until Date = ngày tạo + 7 năm. 🛡️
  • Đây là giải pháp chuẩn theo best practice AWS cho dữ liệu tuân thủ pháp lý dài hạn.

❌ Phân tích tất cả các phương án (đúng/sai)

  • Enable governance mode on the S3 bucket. Use a default retention period of 7 years.
    ❌ Sai. Governance mode cho phép người dùng có quyền s3:BypassGovernanceRetention (bao gồm root user nếu cấp quyền) bypass retention để xóa/sửa object trước hạn. Không đáp ứng yêu cầu "root user không được phép". Governance chỉ linh hoạt hơn cho môi trường nội bộ, không dùng cho compliance nghiêm ngặt.

  • Enable compliance mode on the S3 bucket. Use a default retention period of 7 years.
    ✅ Đúng (như đã giải thích ở trên). Hoàn hảo cho yêu cầu bất biến tuyệt đối, áp dụng mặc định cho toàn bucket.

  • Place a legal hold on individual objects in the S3 bucket. Set the retention period to 7 years.
    ❌ Sai. Legal hold chỉ giữ object vô thời hạn cho đến khi explicitly remove hold, không hỗ trợ retention period tự động 7 năm. Nó không có cơ chế hết hạn theo thời gian, và phải áp dụng từng object riêng lẻ (không default cho bucket). Không phù hợp cho quy trình tự động hóa hàng loạt hồ sơ.

  • Set the retention period for individual objects in the S3 bucket to 7 years.
    ❌ Sai. Việc đặt retention từng object riêng lẻ không đảm bảo tính nhất quán cho "mỗi record được tạo" (cần tự động). Hơn nữa, không chỉ rõ mode (Governance/Compliance), nên root user vẫn có thể bypass nếu dùng Governance. Không dùng default bucket-level, dẫn đến dễ lỗi vận hành.

📘 Tài liệu tham khảo (AWS cập nhật 2026)

  • AWS Documentation: S3 Object Lock - Object Lock overview và Retention modes.
  • AWS Well-Architected Framework: Reliability Pillar - Khuyến nghị Compliance mode cho immutable storage.
  • Exam Prep DOP-C02: Chủ đề S3 Security & Compliance (Object Lock chi tiết trong module Storage).
  • Blog AWS: "Using Amazon S3 Object Lock for compliance" (2024 update hỗ trợ default retention mạnh hơn).

Giải pháp này đảm bảo tuân thủ 100% và dễ triển khai với IAM policies. Nếu cần script CloudFormation, tôi có thể hỗ trợ thêm! 🚀

Câu 759
A data engineer needs to create a new empty table in Amazon Athena that has the same schema as an existing table named old_table.

Which SQL statement should the data engineer use to meet this requirement?
  1. A CREATE TABLE new_table AS SELECT * FROM old_tables;
  2. B INSERT INTO new_table SELECT * FROM old_table;
  3. C CREATE TABLE new_table (LIKE old_table);
  4. D CREATE TABLE new_table AS (SELECT * FROM old_table) WITH NO DATA;
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi yêu cầu một data engineer tạo một bảng mới rỗng (empty table) trong Amazon Athena có cùng schema (cấu trúc cột, kiểu dữ liệu, partition keys nếu có) với bảng hiện có tên old_table.

📌 Yêu cầu chính:

  • Bảng mới phải rỗng hoàn toàn (không chứa dữ liệu).
  • Sử dụng câu lệnh SQL phù hợp với Amazon Athena (dựa trên engine Presto/Trino, hỗ trợ DDL Hive-like).
  • Athena là dịch vụ serverless query trên S3, không lưu trữ dữ liệu mà chỉ định nghĩa schema để query.

🛠️ Kiến thức cập nhật (AWS 2024-2026): Athena hỗ trợ CTAS (CREATE TABLE AS SELECT) với tùy chọn WITH NO DATA để tạo bảng rỗng từ query. Cú pháp CREATE TABLE LIKE cũng được hỗ trợ từ engine version 3 (Presto), nhưng cần cú pháp chính xác để loại trừ dữ liệu.

✅ Đáp án đúng: CREATE TABLE new_table AS (SELECT * FROM old_table) WITH NO DATA;

Lý do chọn đáp án này:

  • Đây là cú pháp CTAS (CREATE TABLE AS SELECT) chuẩn của Athena, sao chép schema đầy đủ từ old_table (bao gồm cột, kiểu dữ liệu, partitions).
  • WITH NO DATA đảm bảo bảng mới rỗng 100%, chỉ copy schema mà không insert dữ liệu.
  • Parens quanh SELECT là bắt buộc trong một số engine Athena để tránh lỗi syntax.
  • Hoàn hảo cho yêu cầu: tạo bảng mới rỗng với schema giống hệt.

📋 Giải thích chi tiết tất cả các phương án

Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá đúng/sai dựa trên docs Athena mới nhất:

  • ❌ CREATE TABLE new_table AS SELECT * FROM old_table;
    Sai vì: Câu lệnh CTAS thông thường sẽ copy toàn bộ dữ liệu từ old_table vào bảng mới, dẫn đến bảng không rỗng. Không đáp ứng yêu cầu "empty table". (Lưu ý: Có lỗi chính tả "old_tables" trong lựa chọn gốc, nhưng vẫn sai về logic).

  • ❌ INSERT INTO new_table SELECT * FROM old_table;
    Sai vì: INSERT INTO yêu cầu bảng new_table phải tồn tại trước (không tạo mới). Nếu chạy, sẽ báo lỗi "table does not exist". Không phù hợp để tạo bảng mới.

  • ❌ CREATE TABLE new_table (LIKE old_table);
    Sai vì: Cú pháp không chuẩn trong Athena. Đúng phải là CREATE TABLE new_table LIKE old_table EXCLUDING DATA (hoặc INCLUDING/EXCLUDING tùy chọn từ engine 3+). Phần (LIKE old_table) với parens thừa gây lỗi syntax. Dù CREATE TABLE LIKE hỗ trợ copy schema (và mặc định excluding data), cú pháp sai nên không chạy được.

  • ✅ CREATE TABLE new_table AS (SELECT * FROM old_table) WITH NO DATA;
    Đúng vì: Như giải thích ở trên, CTAS + WITH NO DATA tạo bảng rỗng với schema giống hệt, hỗ trợ đầy đủ partitions/serdes. Hoạt động trên tất cả engine Athena (Presto 0.217+, Trino).

📘 Tài liệu tham khảo (AWS cập nhật 2026)

🛡️ Lưu ý: Trong Athena, schema dựa trên S3 data; chạy query để verify: SHOW CREATE TABLE new_table;. Nếu có partitions, thêm PARTITIONED BY nếu cần!

Câu 760
A data engineer needs to create an Amazon Athena table based on a subset of data from an existing Athena table named cities_world. The cities_world table contains cities that are located around the world. The data engineer must create a new table named cities_us to contain only the cities from cities_world that are located in the US.

Which SQL statement should the data engineer use to meet this requirement?
  1. A INSERT INTO cities_usa (city,state) SELECT city, state FROM cities_world WHERE country=’usa’;
  2. B MOVE city, state FROM cities_world TO cities_usa WHERE country=’usa’;
  3. C INSERT INTO cities_usa SELECT city, state FROM cities_world WHERE country=’usa’;
  4. D UPDATE cities_usa SET (city, state) = (SELECT city, state FROM cities_world WHERE country=’usa’);
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào việc tạo một bảng Amazon Athena mới tên là cities_us, dựa trên một tập con dữ liệu từ bảng hiện có cities_world. Bảng cities_world chứa thông tin về các thành phố trên toàn thế giới. Nhiệm vụ cụ thể là chỉ lấy những thành phố nằm ở US (Mỹ) để đưa vào bảng mới cities_us.

📘 Ngữ cảnh AWS Athena: Athena là dịch vụ serverless query dữ liệu trên S3 bằng SQL chuẩn (dựa trên Presto/Trino engine, cập nhật mới nhất đến 2026 hỗ trợ Trino 400+). Để "tạo bảng mới dựa trên subset", thường cần tạo schema trước (qua CREATE TABLE) rồi INSERT dữ liệu từ query SELECT có điều kiện WHERE. Câu hỏi ngụ ý bảng cities_us (hoặc cities_usa theo option) cần được populate dữ liệu lọc theo country='usa', giả sử schema đã tồn tại hoặc lệnh INSERT sẽ khớp schema.

🛠️ Yêu cầu chính: Sử dụng SQL statement phù hợp để INSERT dữ liệu lọc từ bảng nguồn vào bảng đích, đảm bảo khớp cột và cú pháp hợp lệ trong Athena.

✅ Đáp án đúng

INSERT INTO cities_usa (city,state) SELECT city, state FROM cities_world WHERE country=’usa’;

Lý do lựa chọn:

  • Lệnh này chính xác vì sử dụng INSERT INTO với chỉ định explicit cột đích (city, state), giúp khớp schema bảng cities_usa (giả sử chỉ có 2 cột này).
  • Phần SELECT lọc đúng dữ liệu từ cities_world với điều kiện WHERE country='usa', chỉ lấy thành phố Mỹ.
  • Trong Athena (Trino/Presto), cú pháp này hoàn toàn hợp lệ cho việc insert subset dữ liệu vào bảng đã tồn tại trên S3. Không gây lỗi schema mismatch.
  • ✅ Hiệu quả: Tránh insert full table, chỉ subset, phù hợp với yêu cầu "create ... contain only the cities from ... US".

📋 Phân tích tất cả các phương án

  • INSERT INTO cities_usa (city,state) SELECT city, state FROM cities_world WHERE country=’usa’;
    ✅ Đúng. Như giải thích trên, cú pháp explicit column list đảm bảo dữ liệu chỉ map vào đúng cột city và state, tránh lỗi nếu bảng đích có thêm cột khác (như partition keys). Athena hỗ trợ full, query chạy nhanh trên S3. Hoàn hảo cho subset US cities.

  • MOVE city, state FROM cities_world TO cities_usa WHERE country=’usa’;
    ❌ Sai. MOVE không phải là lệnh SQL chuẩn trong Athena (hay bất kỳ RDBMS nào). Athena chỉ hỗ trợ INSERT, CREATE TABLE AS SELECT (CTAS), MERGE (từ 2023+ với Trino). Lệnh này sẽ báo lỗi syntax ngay lập tức.

  • INSERT INTO cities_usa SELECT city, state FROM cities_world WHERE country=’usa’;
    ❌ Sai. Thiếu column list (city, state) ở phần INSERT INTO. Nếu bảng cities_usa có số cột khác hoặc thứ tự khác (ví dụ thêm country, id), query sẽ thất bại với lỗi column count mismatch. Athena yêu cầu explicit columns cho an toàn, đặc biệt với bảng partitioned trên S3.

  • UPDATE cities_usa SET (city, state) = (SELECT city, state FROM cities_world WHERE country=’usa’);
    ❌ Sai. UPDATE dùng để cập nhật rows hiện có trong bảng đích, không phải tạo/populate mới. Subquery ở đây là correlated scalar (không hợp lệ cho multiple rows), sẽ lỗi "more than one row returned". Athena hỗ trợ UPDATE nhưng chỉ cho bảng Iceberg/Delta (từ 2024+), không phù hợp create new table.

📚 Tài liệu tham khảo (AWS cập nhật 2026)

🛡️ Lưu ý: Nếu muốn tạo bảng hoàn toàn mới mà không CREATE trước, dùng CREATE TABLE cities_us AS SELECT city, state FROM cities_world WHERE country='usa' (CTAS) – nhưng không có trong option, nên INSERT là cách theo đề.