interview-questions
  1. dynamo-db-interview-questions

Dynamo DB Interview Questions & Answers


Basics of DynamoDB:

  1. What is Amazon DynamoDB?

    • Answer: Amazon DynamoDB is a fully managed NoSQL database service provided by AWS that offers fast and predictable performance with seamless scalability.
  2. Explain the key features of DynamoDB.

    • Answer: Key features include automatic scaling, high availability, durability, seamless backup and restore, and low-latency performance.
  3. What are the primary key types in DynamoDB?

    • Answer: DynamoDB supports two primary key types: Partition Key (also known as Hash Key) and Composite Key (Partition Key + Sort Key).
  4. How does DynamoDB achieve scalability and high availability?

    • Answer: DynamoDB achieves scalability and high availability by distributing data across multiple partitions and replicating data across multiple Availability Zones.
  5. What is the consistency model in DynamoDB?

    • Answer: DynamoDB provides eventual consistency by default, but it also allows users to choose strong consistency when reading data.

Data Modeling in DynamoDB:

  1. Explain the concept of Item, Attribute, and Table in DynamoDB.

    • Answer: Items are individual records in a table, attributes are the data elements within items, and tables are the collections of items.
  2. What is a Partition Key?

    • Answer: The Partition Key is a unique identifier for an item in DynamoDB, and it determines the partition (physical storage) where the item is stored.
  3. When would you use a Composite Key in DynamoDB?

    • Answer: Composite keys are used when the uniqueness of an item is determined by a combination of two attributes: Partition Key and Sort Key.
  4. How do you perform a conditional write in DynamoDB?

    • Answer: Conditional writes are performed using the ConditionExpression parameter, allowing you to write an item only if certain conditions are met.
  5. Explain the concept of Local Secondary Index (LSI) in DynamoDB.

    • Answer: LSI is an index with the same partition key as the base table but a different sort key. It allows for querying data with a different sort order.

DynamoDB Queries and Scans:

  1. What is the difference between a Query and a Scan in DynamoDB?

    • Answer: A Query is used to retrieve items based on the key condition, while a Scan reads all items in a table and filters the result based on specified conditions.
  2. How can you efficiently query data in DynamoDB?

    • Answer: Efficient querying involves designing tables with appropriate partition keys and sort keys, and using Global Secondary Indexes (GSIs) when needed.
  3. Explain the concept of FilterExpression in DynamoDB.

    • Answer: FilterExpression is used to further filter the results of a Query or Scan after the initial conditions are met.
  4. When should you use a Global Secondary Index (GSI) in DynamoDB?

    • Answer: GSIs are used when you need to query data based on attributes other than the table's primary key.
  5. What is the significance of the ProjectionExpression parameter?

    • Answer: ProjectionExpression is used to specify the attributes that should be included in the result of a Query or Scan.

DynamoDB Capacity and Throughput:

  1. How does DynamoDB handle scaling?

    • Answer: DynamoDB automatically scales by partitioning data across multiple servers and adjusting the number of partitions based on demand.
  2. Explain the concepts of Provisioned Throughput and On-Demand Capacity in DynamoDB.

    • Answer: Provisioned Throughput requires users to specify the desired read and write capacity, while On-Demand Capacity automatically adjusts based on actual usage.
  3. What is a Write Capacity Unit (WCU) and a Read Capacity Unit (RCU) in DynamoDB?

    • Answer: WCU represents one write per second for an item up to 1 KB, and RCU represents one strongly consistent read per second for an item up to 4 KB.
  4. How can you monitor and optimize DynamoDB throughput?

    • Answer: Monitoring tools like CloudWatch can be used to track throughput metrics, and optimization involves adjusting provisioned capacity and improving data access patterns.
  5. Explain the concept of Auto Scaling in DynamoDB.

    • Answer: Auto Scaling automatically adjusts provisioned throughput capacity in response to changes in demand.

DynamoDB Indexing:

  1. What is a Global Secondary Index (GSI) in DynamoDB?

    • Answer: A GSI is an index with a partition key and optional sort key that is different from the table's primary key.
  2. Can you add a Global Secondary Index to an existing DynamoDB table?

    • Answer: Yes, you can add a GSI to an existing table using the UpdateTable operation.
  3. Explain the concept of Local Secondary Index (LSI) in DynamoDB.

    • Answer: An LSI is an index that has the same partition key as the base table but a different sort key.
  4. When would you use a Local Secondary Index instead of a Global Secondary Index?

    • Answer: LSIs are useful when you need to query data within the same partition key as the base table.
  5. How do you choose between GSI and LSI in DynamoDB?

    • Answer: Choose GSI when you need to query across partition keys, and LSI when you need to query within the same partition key.

DynamoDB Streams:

  1. What is DynamoDB Streams?

    • Answer: DynamoDB Streams capture changes to items in a table and allow for responding to these changes in real-time.
  2. How can you enable DynamoDB Streams on a table?

    • Answer: Streams can be enabled when creating a table or by modifying an existing table using the UpdateTable operation.
  3. Explain the concept of the Shard in DynamoDB Streams.

    • Answer: A Shard is a sequence of stream records in DynamoDB Streams, and it represents a unit of parallel processing.
  4. What are the use cases for DynamoDB Streams?

    • Answer: Use cases include data replication, change notification, and maintaining secondary indexes.
  5. How do you consume and process records from DynamoDB Streams?

    • Answer: Consumers can use AWS Lambda or other applications to process records from DynamoDB Streams.

DynamoDB Backup and Restore:

  1. What is the importance of backup in DynamoDB?

    • Answer: Backups in DynamoDB provide a way to recover data in case of accidental deletion or corruption.
  2. How can you perform a backup in DynamoDB?

    • Answer: Backups can be performed using on-demand backup, continuous backups, or point-in-time recovery.
  3. Explain the difference between on-demand backup and continuous backup in DynamoDB.

    • Answer: On-demand backup is manually triggered, while continuous backup is automatically performed and allows for point-in-time recovery.
  4. What is Point-in-Time Recovery (PITR) in DynamoDB?

Answer:* PITR allows you to restore a table to any specific point in time within the last 35 days.

  1. How do you restore a DynamoDB table from a backup?
    • Answer: You can restore a table using the RestoreTableToPointInTime operation.

Security in DynamoDB:

  1. How is data encrypted in DynamoDB?

    • Answer: Data at rest is encrypted by default, and you can enable server-side encryption for data in transit using HTTPS.
  2. Explain the role of AWS Identity and Access Management (IAM) in DynamoDB.

    • Answer: IAM is used to control access to DynamoDB resources, allowing you to specify who can access which resources and what actions they can perform.
  3. What are fine-grained access controls in DynamoDB?

    • Answer: Fine-grained access controls allow you to control access to individual items or attributes in a table.
  4. How do you implement data validation and input validation in DynamoDB?

    • Answer: You can use conditional expressions and input validation to ensure data integrity and validity.
  5. What is the significance of the ExpressionAttributeValues parameter in DynamoDB?

    • Answer: ExpressionAttributeValues is used to substitute values in expression strings, providing a way to avoid hardcoding values in queries.

Advanced DynamoDB Concepts:

  1. What is the significance of Consistent Reads in DynamoDB?

    • Answer: Consistent Reads in DynamoDB provide a read-after-write consistency, ensuring that reads reflect the most recent write.
  2. Explain the concept of Conditional Writes in DynamoDB.

    • Answer: Conditional Writes allow you to write an item to the table only if certain conditions are met.
  3. What are the best practices for designing efficient DynamoDB tables?

    • Answer: Best practices include choosing appropriate partition keys, using GSIs wisely, and avoiding hot keys.
  4. How does DynamoDB handle hot keys, and what are the implications?

    • Answer: Hot keys can lead to uneven distribution of workload, and DynamoDB mitigates this by automatically splitting and merging partitions.
  5. What is the purpose of the BatchWriteItem operation in DynamoDB?

    • Answer: BatchWriteItem allows you to write or delete multiple items across multiple tables in a single request.

DynamoDB and Serverless Architecture:

  1. How can you integrate DynamoDB with AWS Lambda?

    • Answer: AWS Lambda functions can be triggered by DynamoDB Streams, allowing for real-time processing of changes.
  2. What is the role of Amazon API Gateway in DynamoDB applications?

    • Answer: API Gateway can be used to create RESTful APIs for DynamoDB, allowing for external applications to interact with the database.
  3. Explain the concept of DynamoDB Accelerator (DAX).

    • Answer: DAX is an in-memory caching service that can be used to speed up read-intensive DynamoDB workloads.
  4. What are the advantages of using DynamoDB with AWS AppSync?

    • Answer: AppSync simplifies the process of developing GraphQL APIs for DynamoDB, providing features like real-time data synchronization.
  5. How does DynamoDB fit into a serverless architecture?

    • Answer: DynamoDB is a fully managed and serverless NoSQL database service, making it well-suited for serverless architectures where infrastructure management is abstracted.