2: Data Store Management

    Choose a Data Store

    The first decision the AWS data engineer makes in any pipeline is not which transform to run, it is where the bytes will land. Picking the wrong store forces compensating engineering downstream: bolting a key-value cache in front of an analytical warehouse, building an external secondary index on top of a relational primary, or paying scan-time costs on a lake when the access pattern is point-lookup. The exam tests this decision under tight scenarios: a one-paragraph workload description with a constraint (latency, cost, concurrency, consistency, multi-Region, ad-hoc SQL, vector search) and four nearly plausible AWS services as options. The right answer comes from matching three orthogonal axes: the access pattern (point lookup, range scan, full scan, vector similarity, streaming append), the consistency and durability floor required, and the economic model (steady predictable cost vs. pay-per-query vs. pay-per-second compute).

    The current AWS analytical storage portfolio breaks into four families. The operational family covers low-latency reads and writes on bounded keys: Amazon DynamoDB for serverless key-value and document, Amazon MemoryDB for Redis-compatible durable in-memory, Amazon ElastiCache for Redis or Memcached in-memory caching, Amazon RDS for managed relational engines (MySQL, PostgreSQL, MariaDB, Oracle, SQL Server), and Amazon Aurora for cloud-native MySQL- and PostgreSQL-compatible engines with separated compute and storage. The analytical family covers columnar massively parallel processing: Amazon Redshift (provisioned RA3 or Redshift Serverless) for warehouse SQL, Amazon Athena for serverless Presto/Trino SQL over Amazon S3, and Amazon EMR (Hadoop, Spark, Hive, Trino) for managed open-source clusters. The lake family covers cheap object storage with open table formats: Amazon S3 with Apache Iceberg or Apache Hudi tables, governed by the AWS Glue Data Catalog and AWS Lake Formation, with Amazon S3 Tables providing a managed Iceberg bucket type. The search and vector family covers Amazon OpenSearch Service for full-text and vector, Amazon Aurora PostgreSQL with the pgvector extension, Amazon DocumentDB with vector search, and Amazon Bedrock knowledge bases as the managed retrieval layer.

    A practical decision rule: if the workload performs hundreds of thousands of single-item operations per second with millisecond response and a fixed key, DynamoDB; if it performs cache-only reads with sub-millisecond response, MemoryDB or ElastiCache; if it performs ad-hoc analytical SQL over many gigabytes to petabytes with predictable concurrency, Amazon Redshift; if the same SQL is intermittent or low-volume, Amazon Athena over Amazon S3; if the data is unstructured at scale and accessed by many engines, Amazon S3 with Apache Iceberg; if the lookup is "find me the K most similar vectors", an HNSW or IVF index on Amazon OpenSearch Service or Aurora PostgreSQL pgvector. The mistake the exam punishes is asking a service to do what it is not built for: running OLAP joins on DynamoDB by scanning, running OLTP transactions on Amazon Athena, or running unbounded ad-hoc SQL on a 16-shard Amazon Kinesis Data Streams.

    Workload shape Right service Why
    ------------------------------------ ------------------------ -----------------------------
    Point lookup, single-digit ms, scale Amazon DynamoDB Partitioned key, on-demand
    Sub-ms cache reads Amazon MemoryDB / ElastiCache In-memory, microsecond
    Multi-table joins, ACID, OLTP Amazon RDS / Aurora Managed relational
    Analytical SQL, predictable, BI Amazon Redshift (RA3) MPP columnar, concurrency
    Ad-hoc analytical SQL, intermittent Amazon Athena Serverless, pay-per-scan
    Cheap object store, multi-engine Amazon S3 + Apache Iceberg Open format, lake-wide
    Vector similarity, KB scale Aurora PostgreSQL + pgvector HNSW / IVFFlat in-DB
    Vector similarity, retrieval at scale Amazon OpenSearch Service Native k-NN with HNSW
    

    💡 Exam Trap: A stem that says "low-latency point lookup at scale" almost always wants Amazon DynamoDB. A stem that adds "with complex joins across customer, order, and address tables" wants Amazon Aurora or Amazon RDS instead. Reading only the first half and picking DynamoDB is the most common trap on this domain.

    Vector index types: HNSW and IVF

    Vector workloads moved into the data engineer's surface area because retrieval-augmented generation pipelines feed Amazon Bedrock and SageMaker AI from a vector store the engineer builds and operates. The exam expects you to recognize the two dominant approximate nearest neighbor (ANN) algorithms: Hierarchical Navigable Small Worlds (HNSW) and Inverted File (IVF), in particular its IVFFlat form.

    HNSW builds a multi-layer proximity graph. At query time the search descends layers from a sparse top to a dense bottom, hopping along neighbor edges that are guaranteed by construction to be short. Recall is high (often above 95 percent), latency is low, and the structure tolerates inserts well, which matters because chunked documents arrive continuously. The trade is memory: the graph itself is stored alongside the vectors, and large indexes can consume tens of gigabytes per million 1024-dimension vectors. HNSW is the default for Amazon OpenSearch Service k-NN, the recommended index in Amazon Aurora PostgreSQL pgvector when memory permits, and the index type used by Amazon MemoryDB vector search.

    IVF partitions the vector space into Voronoi cells around nlist centroids using k-means at build time. At query time, the engine probes only nprobe nearest cells, scanning their inverted lists linearly. Recall is a tunable trade against nprobe: probing more cells raises recall and cost. IVF is cheaper in memory and faster to build at very large scale, but it requires a representative training corpus and re-training when data drift shifts the centroid geometry. IVF is appropriate when the corpus is mostly static and the index must fit in less memory than HNSW would need; pgvector exposes it as ivfflat.

    -- Aurora PostgreSQL pgvector: HNSW vs IVFFlat
    CREATE EXTENSION IF NOT EXISTS vector;
    
    CREATE TABLE doc_chunks (
     chunk_id BIGINT PRIMARY KEY,
     doc_id BIGINT NOT NULL,
     body TEXT NOT NULL,
     embedding vector(1024) NOT NULL
    );
    
    -- HNSW: build once, ingest continuously, low query latency
    CREATE INDEX doc_chunks_hnsw
     ON doc_chunks
     USING hnsw (embedding vector_cosine_ops)
     WITH (m = 16, ef_construction = 64);
    
    -- IVFFlat: cheaper memory footprint, requires a representative sample
    CREATE INDEX doc_chunks_ivf
     ON doc_chunks
     USING ivfflat (embedding vector_cosine_ops)
     WITH (lists = 1000);
    
    SET hnsw.ef_search = 40;
    SET ivfflat.probes = 10;
    
    SELECT chunk_id, body
    FROM doc_chunks
    ORDER BY embedding <=> :query_vec
    LIMIT 8;
    

    Lifecycle of data starts at the store choice

    Lifecycle is not a separate workstream. The same decision that places data in a store also decides whether it gets cheap with age (Amazon S3 with lifecycle policies), expires automatically (Amazon DynamoDB TTL), or stays at full cost forever (uncontrolled Amazon RDS storage growth). The exam frequently asks the engineer to design a pipeline that ingests now-hot data into one tier, hands it off to a colder tier after a window, then deletes it on a legal hold timer. Recognizing that the answer is "configure an S3 Lifecycle policy on the curated prefix to transition to S3 Standard-IA after 30 days and S3 Glacier Flexible Retrieval after 180 days, then expire at the retention boundary" is faster when lifecycle is built into the store choice from the start.

    Schema design across Amazon Redshift, Amazon DynamoDB, and AWS Lake Formation

    Each of the three primary stores wants a different schema philosophy. Amazon Redshift wants a star or snowflake schema with a chosen distribution style (KEY, EVEN, ALL, or AUTO) and a sort key picked so the join column on the fact table colocates with the dimension and the sort key matches the predicate of the most common range scan. Amazon DynamoDB wants a single-table design where the partition key gives even traffic spread (high cardinality, no hot key), the sort key encodes the access pattern (composite, hierarchical, or temporal), and global secondary indexes (GSIs) add alternate access keys for the same item. AWS Lake Formation governs tables that physically live on Amazon S3 with a logical schema in the AWS Glue Data Catalog; the schema design problem here is partitioning, column types, and the table format (Apache Iceberg if you want schema evolution and ACID).

    -- Redshift star schema with distribution + sort keys
    CREATE TABLE fact_orders (
     order_id BIGINT NOT NULL,
     customer_id BIGINT NOT NULL,
     order_ts TIMESTAMP NOT NULL,
     amount_usd DECIMAL(12,2)
    )
    DISTKEY (customer_id)
    SORTKEY (order_ts);
    
    CREATE TABLE dim_customer (
     customer_id BIGINT NOT NULL,
     region VARCHAR(32),
     signup_dt DATE
    )
    DISTSTYLE ALL;
    

    ⚠️ Anti-Pattern: Defaulting every Redshift fact table to DISTSTYLE EVEN. EVEN spreads rows round-robin, which is acceptable for staging but forces a broadcast or redistribute on every join. For a fact-dim join, distribute the fact on the join key and replicate small dims with DISTSTYLE ALL.

    🎯 Scenario: A finance team needs a daily dashboard joining 18 months of orders to a 30 thousand row customer dimension. Twelve analysts query concurrently. You pick Amazon Redshift RA3 with customer_id as the fact distribution key, order_ts as the sort key, and DISTSTYLE ALL on the dim. Queries hit the predicate on the sort key, get a colocated join, and run without redistribution.

    Decision Anchor. Choose Amazon DynamoDB when the access pattern is bounded by a known key and you need single-digit millisecond reads at any scale. Choose Amazon Redshift when the same data is asked open-ended analytical SQL by many users. Choose Amazon S3 with Apache Iceberg when the data must be read by Spark, Trino, Athena, and Redshift Spectrum without copying.

    📊 Limit: A single DynamoDB partition supports up to 3,000 read capacity units and 1,000 write capacity units per second before adaptive capacity must spread the workload across more partitions. A hot partition above these throughputs is the most common DynamoDB performance failure.

    💡 Exam Trap: When a stem mentions "vectors" or "embeddings" plus "Amazon Bedrock", the right answer is almost never DynamoDB or Redshift; it is Amazon OpenSearch Service with k-NN, Aurora PostgreSQL with pgvector, Amazon MemoryDB vector search, or an Amazon Bedrock knowledge base. Reflexively picking DynamoDB because "fast key-value" is a trap.

    Decision Tree: Initial Store Selection

    The decision tree is conservative; the right answer in exam scenarios is usually the cheapest store that meets every stated requirement, not the most flexible store you can name.


    Continue with the interactive course

    Track your progress, jump into practice questions and use the Shark AI tutor inside the AWS - Data Engineer Associate learning hub.