Section: Exam Notes
Section: Practice Tests

Using Data Stores in Application Development

This section aligns with the following AWS Certified Developer – Associate (DVA-C02) exam objectives:

Domain 1: Development with AWS Services
Task 3: Use data stores in application development


1. Choosing Between Relational and Non-Relational Databases in AWS

Selecting the correct database service is a core skill for AWS developers. AWS provides both relational (SQL) and non-relational (NoSQL) data stores, each optimized for different application requirements.

Relational databases are structured, table-based systems that support ACID transactions and complex queries. AWS provides managed relational databases through Amazon RDS and Amazon Aurora. These services are well suited for applications that require transactional integrity, strict schemas, and joins—such as financial systems and e-commerce platforms.

Non-relational databases are schema-less and optimized for scalability and performance. Amazon DynamoDB is a fully managed key-value and document database designed for single-digit millisecond latency at scale. Other NoSQL options include Amazon DocumentDB and in-memory caching solutions such as Amazon ElastiCache.

Exam Tips

  • Use RDS or Aurora when transactions, joins, and ACID compliance are required.
  • Choose DynamoDB for highly scalable, low-latency key-value workloads.
  • Use ElastiCache to reduce database load by caching frequently accessed data.

2. CRUD Operations in AWS Databases

CRUD operations—Create, Read, Update, and Delete—are fundamental to application development and differ slightly depending on the database engine.

In DynamoDB, CRUD operations are performed using AWS SDKs such as boto3, and they operate directly on items using primary keys.

import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Users')

# Create
table.put_item(Item={'UserId': '123', 'Name': 'Alice', 'Age': 25})

# Read
response = table.get_item(Key={'UserId': '123'})
print(response['Item'])

# Update
table.update_item(
    Key={'UserId': '123'},
    UpdateExpression="SET Age = :age",
    ExpressionAttributeValues={':age': 26}
)

# Delete
table.delete_item(Key={'UserId': '123'})

Relational databases such as RDS use SQL-based queries and standard database drivers.

import pymysql
connection = pymysql.connect(
    host='db.example.com',
    user='admin',
    password='mypassword',
    database='users_db'
)

with connection.cursor() as cursor:
    cursor.execute("INSERT INTO users VALUES (1, 'Alice', 25)")
    connection.commit()

    cursor.execute("SELECT * FROM users WHERE id=1")
    print(cursor.fetchone())

    cursor.execute("UPDATE users SET age=26 WHERE id=1")
    connection.commit()

    cursor.execute("DELETE FROM users WHERE id=1")
    connection.commit()

Exam Tips

  • DynamoDB delivers consistent single-digit millisecond performance.
  • RDS is preferred for complex queries and transactional workloads.
  • Use AWS SDKs (such as boto3) for programmatic access to AWS services.

3. High-Cardinality Partition Keys in DynamoDB

Partition key design directly affects DynamoDB performance. High-cardinality keys distribute data evenly across partitions, preventing throttling and performance degradation.

Low-cardinality keys (for example, region names like us-east-1) can create hot partitions, while high-cardinality keys such as unique user IDs ensure balanced throughput.

Exam Tips

  • Always prefer unique or near-unique values for partition keys.
  • Avoid commonly repeated values like role names or regions.
  • When uniqueness is limited, use a composite primary key with a sort key.

4. Cloud Storage Options in AWS

AWS offers multiple storage services optimized for different access patterns.

  • File storage: Amazon EFS provides a shared file system accessible by multiple EC2 instances.
  • Block storage: Amazon EBS offers persistent, low-latency storage attached to EC2 instances.
  • Object storage: Amazon S3 stores data as objects and scales virtually without limit.

Exam Tips

  • Use S3 for media files, backups, and static assets.
  • Use EFS when multiple instances require shared file access.
  • Use EBS for boot volumes and high-performance workloads.

5. Database Consistency Models

AWS data stores support different consistency models depending on the service and configuration.

Strongly consistent reads ensure that data returned reflects the most recent write, which is essential for financial or transactional systems. Eventually consistent reads may temporarily return stale data but offer higher availability and lower latency.

Exam Tips

  • Choose strong consistency when correctness is critical.
  • Use eventual consistency for scalable, read-heavy workloads.

6. Query vs. Scan Operations in DynamoDB

DynamoDB provides two primary methods for retrieving data.

A Query operation retrieves items using a specific partition key and is highly efficient. A Scan operation examines every item in a table, making it slower and more resource-intensive.

# Query
response = table.query(
    KeyConditionExpression=Key('UserId').eq('123')
)

# Scan
response = table.scan()

Exam Tips

  • Prefer Query over Scan whenever possible.
  • Avoid Scan operations in performance-sensitive applications.

7. DynamoDB Keys and Indexes

Every DynamoDB table requires a primary key, which can be simple or composite.

  • Partition key: Determines data distribution.
  • Sort key: Enables multiple items within the same partition.

DynamoDB also supports secondary indexes:

  • Local Secondary Index (LSI) uses the same partition key with a different sort key.
  • Global Secondary Index (GSI) allows querying on alternate partition keys.

Exam Tips

  • Use LSIs for alternative sorting within a partition.
  • Use GSIs to support new access patterns without table redesign.

8. Caching Strategies in AWS

Caching improves performance and reduces database load. Common strategies include write-through, read-through, lazy loading, and TTL-based expiration.

import redis
cache = redis.StrictRedis(host='mycache.example.cache.amazonaws.com', port=6379)
cache.set("username", "Alice", ex=3600)
print(cache.get("username"))

Exam Tips

  • Use ElastiCache (Redis or Memcached) for low-latency access.
  • Lazy loading caches data only when requested.
  • Always use TTL to prevent stale data.

9. Amazon S3 Storage Classes and Lifecycle Management

S3 provides multiple storage tiers optimized for different access patterns, from Standard to Glacier Deep Archive. Lifecycle policies automate transitions between these tiers.

Exam Tips

  • Use S3 Standard for frequently accessed data.
  • Use Glacier or Deep Archive for long-term, infrequently accessed data.
  • Apply lifecycle rules to reduce storage costs automatically.

Final Exam Checklist

  • Understand when to use RDS versus DynamoDB.
  • Know DynamoDB keys, indexes, and access patterns.
  • Distinguish between Query and Scan operations.
  • Apply appropriate caching strategies using ElastiCache.
  • Choose correct S3 storage classes and lifecycle rules.

This topic is frequently tested and forms the foundation for many real-world AWS application architectures.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Hide picture