Top 25 DynamoDB Interview Questions & Answers [2024]
Written by Nishani Dissanayake
Published on March 8th, 2022
Time to 10x your DynamoDB productivity with Dynobase [learn more]
Q1. What is DynamoDB?
DynamoDB is a fully managed NoSQL database service provided by AWS. It offers features like seamless scalability, fast performance, and high reliability. DynamoDB supports both key-value and document data structures, making it versatile for various use cases. Additionally, it comes with different pricing tiers to suit varying user requirements, ensuring cost-effectiveness.
DynamoDB is highly effective at data storage and retrieval across all traffic levels, allowing users to create tables for their databases with ease.
02. What are NoSQL databases?
NoSQL or non-relational databases focus on different data storage models rather than a tabular structure. There are four types of NoSQL databases:
- Key-value stores
- Document stores
- Graph stores
- Column stores
DynamoDB supports both document and key-value structures, making it flexible for various application needs.
03. What are the key features of DynamoDB?
- Highly scalable without any intervention from the user.
- It has a latency of microseconds.
- Serverless and enterprise-ready.
- Encryption at Rest.
- On-demand backup and restore.
- Point-in-time recovery.
Read more: DynamoDB Features.
04. What are the advantages of using DynamoDB?
- Unlimited storage capacity, allowing you to store any amount of data.
- Data replication across multiple availability zones, ensuring high availability and durability.
- Cost-effective, with a pay-as-you-go pricing model.
- Fully managed by AWS, eliminating the need for software patching, setup, and configuration.
- Advanced reporting and secure user authentication mechanisms to protect sensitive data.
Read more: DynamoDB Pros & Cons.
05. What are the disadvantages of DynamoDB?
- No support for triggers and server-side scripts.
- No table joins possible.
- Limited querying capabilities.
- Unpredictable costs with spikes in usage.
06. What are the use cases of DynamoDB?
- Daily web analytics
- Real-time analytics
- Data warehousing
- Business Intelligence
07. What is DynamoDBMapper?
The DynamoDBMapper class is an entry point that allows access to DynamoDB endpoints, enabling users to handle the database. Users can perform CRUD operations, run queries, and scan against tables. This class is available only for Java, making it a specialized tool for Java developers.
Read more: DynamoDBMapper.
08. What is meant by Partition Key in DynamoDB?
A partition key is a primary key composed of only a single attribute. In DynamoDB, the value of the partition key serves as the input for internal hash functions. The resulting output from that function helps determine the partition to store the item in question.
09. How does DynamoDB Query functionality work?
DynamoDB provides two options to fetch data: Query and Scan. When using Scan, DynamoDB will look through the entire table for records that match the criteria, while Query uses key constraints to perform a direct lookup for a particular data set.
In addition to the primary key, DynamoDB uses global secondary indexes, local secondary indexes, and partition keys to improve flexibility and enhance read/write operation speed.
As a result, Query is faster and more time-effective compared to the Scan operation and is recommended for most data-fetching scenarios.
10. What are the key differences between Amazon DynamoDB and Amazon Aurora?
- DynamoDB is NoSQL, whereas Aurora is a relational database service.
- Aurora uses SQL for data manipulation and fetching, whereas DynamoDB uses a specialized syntax.
- Aurora uses horizontal partitioning, whereas DynamoDB uses sharding as the partitioning method.
- DynamoDB implements key-value and document models, whereas Aurora operates with relational DBMS.
- Aurora supports server-side scripting, but DynamoDB does not.
Read more: DynamoDB vs. Aurora.
11. List 5 ways to fetch data from DynamoDB
- GetItem
- Query
- Scan
- BatchGet
- TransactRead
12. What are DynamoDB Projections?
Projections in DynamoDB refer to the attributes in a table that are projected to the index. Projections can exclude unnecessary items and reduce the overall size of the payload returned by the API.
When creating a local secondary index, you must define the projected attributes. Each index must have at least three attributes: table partition key, index sort key, and table sort key.
Read more: DynamoDB Projections.
13. How does DynamoDB prevent data loss?
DynamoDB employs long-term storage and a two-tier backup system to minimize data loss. Each partition is replicated across three nodes, each containing the same data. Additionally, DynamoDB uses a B-tree for data location and a replication log to track changes. Snapshots of these are stored in another AWS database for up to a month for data restoration when necessary.
14. Does DynamoDB support in-place atomic updates?
DynamoDB supports quick in-place atomic updates, enabling users to add or remove values to sets or lists at the atomic level using Transactions.
15. What are DynamoDB Streams?
DynamoDB Streams capture the time-ordered sequence of item-level modifications made to a DynamoDB table. This information is saved in a log for 24 hours, and each modification is recorded sequentially in the order it was made.
Read more: DynamoDB Streams.
16. What are the DynamoDB pricing tiers?
- On-demand capacity mode: This pricing tier focuses on the incoming traffic to the application and scales the database instance based on that. This pricing tier is ideal when the traffic is not predictable.
- Provisioned capacity mode: This pricing tier lets users specify the reads and writes per second or choose auto-scaling. This option works best when the traffic is consistent and predictable.
Read more: DynamoDB Pricing.
17. What is the maximum item size in Amazon DynamoDB?
400KB
Including both the attribute name length and the value lengths in binary format, 400KB is the maximum item size.
18. What is DynamoDB Auto Scaling?
Most of the time, it is hard to predict the database's workload. So, DynamoDB introduced DynamoDB Auto Scaling to scale the read and write capacity in response to traffic.
Scaling up allows the tables or the global secondary indexes to gain more read and write capacity. Scaling down automatically based on the traffic makes DynamoDB cost-effective to use.
19. What is the DynamoDB Local?
DynamoDB Local is a downloadable version of DynamoDB. It allows developing and testing applications in the local environment without using the DynamoDB web service. Once the application is ready for deployment, the local endpoint can be changed and redirected to the DynamoDB web service.
20. How many Global Secondary Indexes can you create on a single table?
Up to 20 Global Secondary Indexes.
21. What is Encryption at Rest?
Encryption at Rest is a security mechanism DynamoDB uses to protect sensitive data. This database service uses the AWS KMS (AWS Key Management Service) keys to encrypt all the data at rest. There are three types of AWS KMS keys to select from:
- AWS owned key
- AWS managed key
- Customer managed key
Read more: Encryption at Rest.
22. What is DynamoDB Accelerator?
DAX (Amazon DynamoDB Accelerator) is a type of in-memory cache. Even when handling millions of requests per second, DynamoDB Accelerator provides performance up to 10 times faster than the original rate. Additionally, it is fully managed and highly available.
Read more: DAX.
23. What are DynamoDB Global Tables?
DynamoDB Global Tables allow users to replicate their data across different regions of choice. This makes the data highly available and quickly delivered across global applications of enormous size. Every data write made to a global table is replicated across all regions having replicas of the same table.
24. What does BatchGetItem do in DynamoDB?
BatchGetItem
allows retrieving attributes of one or more items from one or more tables using the primary key. There is a limitation of 16MB up to which this operation can return items.
Read more: BatchGetItem.
25. What are Indexes and Secondary Indexes in DynamoDB?
An index is a data structure that enhances the data retrieval speed from the database. However, it costs some storage space and additional writes to the database to maintain the index data structure.
DynamoDB has two types of indexes:
- Global secondary index
- Local secondary index
Secondary indexes allow the storage of a sub-group of attributes from a table. With that, it supports query functionality with alternate keys.
Closing Thoughts
This article discussed 25 of the top questions you may face about DynamoDB in an interview. DynamoDB is a developing technology becoming a huge asset amongst the NoSQL database services. Because of that, positions are opening up for individuals passionate about working with this fantastic service.
So, I hope you find this article helpful to crush your next interview with confidence!