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
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
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
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
AWS offers multiple storage services optimized for different access patterns.
Exam Tips
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
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
Every DynamoDB table requires a primary key, which can be simple or composite.
DynamoDB also supports secondary indexes:
Exam Tips
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
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
This topic is frequently tested and forms the foundation for many real-world AWS application architectures.