Practice Test

Multiple Choice Question: What are the two types of keys in Amazon DynamoDB?

  • A. Primary and Secondary
  • B. Partition and Sort
  • C. Local and Global
  • D. Range and Hash

Answer: B. Partition and Sort

Explanation: Amazon DynamoDB mainly uses two types of keys for data access purposes: Partition key and Sort key.

True/False: The primary key attribute(s) must all be unique in Amazon DynamoDB.

Answer: True.

Explanation: The primary key uniquely identifies each item in a table, thus it must be unique for every item.

Multiple Select Questions: Which of the following statements are true about Partition Key and Sort Key in DynamoDB?

  • A. A partition key is used to distribute data across partitions for scalability
  • B. A sort key allows us to order the data within each partition
  • C. A partition key should be evenly distributed to optimize performance
  • D. A sort key is also known as hash key

Answer: A, B, C

Explanation: All statements are true except D. A partition key is also known as the hash key.

True/False: Secondary indexes in DynamoDB are used to query data with attributes other than the primary key.

Answer: True

Explanation: Secondary indexes can be understood as ‘sub-tables’ within your main table, which you can create to query your data based on non-primary key attributes.

Multiple Choice Question: How many types of secondary indexes does DynamoDB support?

  • A. 1
  • B. 2
  • C. 3
  • D. 4

Answer: B. 2

Explanation: DynamoDB supports two types of secondary indexes: Global Secondary Indexes (GSI) and Local Secondary Indexes (LSI).

True/False: A secondary index automatically has the same throughput settings as its main table in Amazon DynamoDB.

Answer: False

Explanation: Throughput settings for secondary indexes in DynamoDB are managed separately from the main table.

Multiple Select Questions: Which of the following statements are true about Global Secondary Indexes (GSIs)?

  • A. GSIs must have the same partition key and sort key as the base table
  • B. GSIs can have separate partition key and sort key as the base table
  • C. GSIs can have different throughput limits than the base table
  • D. GSIs cannot be queried directly

Answer: B, C

Explanation: Global Secondary Indexes can have different partition, sort keys and different read/write capacity settings than the base table. Also, it can be queried directly.

True/False: Amazon DynamoDB supports consistent reads on the table data and secondary index data.

Answer: True

Explanation: DynamoDB supports both eventual consistent reads (default) and strongly consistent reads on the table and secondary index data.

Multiple Choice Question: Partition key’s value in DynamoDB is also called __

  • A. Hash attribute
  • B. Key attribute
  • C. Value attribute
  • D. Sort attribute

Answer: A. Hash attribute

Explanation: The partition key of DynamoDB is also referred to as a hash attribute.

True/False: You cannot delete a global secondary index from a table after it is created.

Answer: False

Explanation: You can delete a Global Secondary Index even after the table is created.

Multiple Choice Question: What are DynamoDB Streams?

  • A. A series of sorted logs for each database operation
  • B. A way to replicate DynamoDB data across AWS regions
  • C. A global secondary index
  • D. A method of data backup

Answer: A. A series of sorted logs for each database operation

Explanation: DynamoDB Streams captures table activity, and each stream record appears exactly once in the stream.

True/False: DynamoDB automatically manages indexes so that they don’t exceed their provisioned throughput

Answer: True

Explanation: DynamoDB offers automatic scaling of throughput capacity, ensuring that indexes do not exceed their provisioned throughput.

Multiple Choice Question: Maximum length of the partition key value in DynamoDB is:

  • A. 2KB
  • B. 256 KB
  • C. 1MB
  • D. 512 KB

Answer: A. 2KB

Explanation: The maximum length of a partition key value is 2 KB.

True/False: Local Secondary Index (LSI) provides an alternate sort key for a given partition key value.

Answer: True

Explanation: LSI provides an alternate sort key for a given partition key value along with different subset of attributes.

Multiple Choice Question: What is the maximum limit of GSIs that can be created per table in DynamoDB?

  • A. 5
  • B. 10
  • C. 20
  • D. 25

Answer: C. 20

Explanation: Amazon DynamoDB allows up to 20 GSIs per table by default.

Interview Questions

1. What are the two types of primary keys used in Amazon DynamoDB?

Partition key and composite key.

2. How does DynamoDB distribute data for a table with a composite primary key?

DynamoDB distributes data by the partition key value, and the sort key value is used to order items with the same partition key.

3. How are local secondary indexes different from global secondary indexes in DynamoDB?

Local secondary indexes have the same partition key as the table but a different sort key, while global secondary indexes have different partition and sort keys from the table.

4. What is the primary purpose of secondary indexes in DynamoDB?

Secondary indexes allow querying a table based on attributes other than the primary key to improve query performance.

5. Can you add a secondary index to an existing DynamoDB table?

Yes, you can add secondary indexes to existing tables in DynamoDB.

6. How does DynamoDB handle the indexing of items with the same partition key?

Items with the same partition key are stored in sort key order, which allows for efficient querying using the sort key.

7. What is the purpose of a sparse index in DynamoDB?

Sparse indexes allow for efficient querying when a subset of items in a table have a particular attribute.

8. How does DynamoDB handle indexing of attributes with different data types?

Attributes with different data types are indexed separately by DynamoDB, allowing for efficient querying based on different data types.

9. Can you query DynamoDB using secondary indexes even if the primary key of a table is not known?

Yes, secondary indexes enable querying a table based on attributes other than the primary key, providing flexibility in query options.

10. What is the main benefit of using secondary indexes in DynamoDB?

Secondary indexes improve query performance by allowing efficient access to data based on attributes other than the primary key.

Leave a Reply

Your email address will not be published. Required fields are marked *