This quiz is part of the DevOpsTheHardWay course.

Please answer the quiz and click the "Test" button at the bottom right.

AWS - DynamoDB - multichoice questions

Question 1

You are designing a highly scalable application that utilizes DynamoDB for its database needs. The application is expected to handle a maximum of 1000 reads/second and 500 writes/second. Items average size is 4 KB.

How many RCU and WCU are required?

Question 2

You're team is developing a news website that receives an average of 500 read requests per second during peak hours. Each news article is approximately 10 KB in size.

Which of the following is a proper DB design?

Question 3

Consider the following JSON sample of an item in an DynamoDB table:

{
    "item_id": "123456789",
    "timestamp": "2022-05-10T10:30:00Z",
    "name": "Product A",
    "category": "Electronics",
    "price": 99.99,
    "quantity": 10
}

Which attribute from the item JSON sample would be most suitable as the partition key for the DynamoDB table?

Question 4

Consider a scenario for an e-commerce site that uses DynamoDB to store orders data. The most common query is retrieval of order history per customer.

What would be the most suitable choice for the primary key?

Suppose you have a DynamoDB table named "ProductCatalog" designed to store product information. The table has a primary key ProductID and a global secondary index (GSI) named CategoryIndex with the partition key Category and sort key ProductID.

Answer the below 2 questions.

Question 5

You've just written a new product data into the table. Then, immediately, retrieve the data, as follows:

import boto3

# Initialize DynamoDB client
dynamodb = boto3.client('dynamodb')

# Write data to the table
dynamodb.put_item(
    TableName='ProductCatalog',
    Item={
        'ProductID': {'S': '123'},
        'Name': {'S': 'Example Product'},
        'Category': {'S': 'Electronics'}
    }
)

# Retrieve the data
response = dynamodb.get_item(
    TableName='ProductCatalog',
    Key={
        'ProductID': {'S': '123'}
    },
    ConsistentRead=True  # Ensure strong consistency
)

print(response['Item'])

What data would be returned by this code?

Question 6

You've just written a new product data into the table. Then, immediately, retrieve the data using the GSI and strongly consistent read.

What would be the outcome of this action?

Question 7

Consider a DynamoDB table with 4 partitions, each containing items:

Partition 1:

[
  {
    "ProductID": "125",
    "Name": "Laptop Pro X",
    "Category": "Electronics"
  },
  {
    "ProductID": "173",
    "Name": "Phone XS Max",
    "Category": "Electronics"
  },
  {
    "ProductID": "199",
    "Name": "Keyboard K2",
    "Category": "Electronics"
  }
]

Partition 2:

[
  {
    "ProductID": "201",
    "Name": "Jacket XL",
    "Category": "Clothes"
  },
  {
    "ProductID": "262",
    "Name": "Shirt M",
    "Category": "Clothes"
  }
]

Partition 3:

[
  {
    "ProductID": "121",
    "Name": "Sneakers 10",
    "Category": "Footwear"
  },
  {
    "ProductID": "234",
    "Name": "Sandals",
    "Category": "Footwear"
  },
  {
     "ProductID": "301",
    "Name": "Boots 8",
    "Category": "Footwear"
  }
]

Partition 4:

[
  {
    "ProductID": "319",
    "Name": "Belt M",
    "Category": "Accessories",
    "Description": "Genuine leather"
  },
  {
    "ProductID": "433",
    "Name": "Sunglasses XL",
    "Category": "Accessories",
    "Description": "Polarized lenses"
  },
  {
    "ProductID": "455",
    "Name": "Watch S",
    "Category": "Accessories",
    "Description": "Water-resistant"
  },
  {
    "ProductID": "728",
    "Name": "Bracelet Gold",
    "Category": "Accessories",
    "Description": "18k gold plated"
  }
]

Now, a new item is added to the table with the following data:

{
  "ProductID": "501",
  "Name": "Backpack",
  "Category": "Accessories",
  "Description": "Laptop compartment"
}

Without knowing the primary key of the table, which partition this new item is most likely to be mapped to?

license