DynamoDB Interview Questions and Answers (2023)
In this post, questions from Dynamodb Interviews will be answered for Experienced and Freshers. We're trying to share our experience and learn how to help you make progress in your career.
AWS DynamoDB Tutorial :
What is DynamoDB?
Is DynamoDB a SQL?
Is DynamoDB free for use?
What are advantages of DynamoDB?
How to generate DynamoDB Access Key and Secret Key?
What is DynamoDBMapper class?
List methods of DynamoDBMapper class?
Is DynamoDBMapper thread safe?
Does Amazon DynamoDB support both increment and decrement atomic operations?
Does DynamoDB support in place atomic updates?
Are DynamoDB writes Atomic?
What kind of query functionality does DynamoDB support?
What is difference between MongoDB and DynamoDB?
Is Redis faster than DynamoDB?
Q: What is DynamoDB?
- Amazon DynamoDB is a fully managed proprietary NoSQL database service that provides fast and predictable performance with seamless scalability.
- It supports key-value and document data structures
- DynamoDB allows users to create tables for your database to store and retrieve any data volume and to support any request traffic level.
Q: Is DynamoDB a SQL?
DynamoDB is NoSQL database, it can handle structured or semi structured data, including JSON
documents. DynamoDB scales to accommodate very large amounts of data and very large number of
SQL is the standard for storing and retrieving data. Relational databases have a wide range of tools available for simplifying the development of database-driven applications, however all of these tools uses SQL.
Q: Is DynamoDB free for use?
Amazon DynamoDB is a fully managed NoSQL licensed database.
You can start with free tier limits of DynamoDB on which many applications runs.
If services are required, the price per month varies depending on the type of resources you need.
Q: What are advantages of DynamoDB?
- Scalable - Unlimited amounts of data can be stored.
- Distributed - DynamoDB scales horizontally by expanding a single table over multiple server.
- Cost Effective - One year free tier provides more than 40 million database operations/month and pricing is based on throughput (read/write per second) than just storage.
- Easy Administration - Fully managed service from Amazon.
- Automatic data replication - All data items are stored on Solid State Disks (SSDs) and automatically replicated across multiple availability zones in a region.
- Secure - DynamoDB security is better and is usually supported by the security measure provided by AWS. In order to authenticate users and prevent unauthorised data access, it uses proven secure techniques.
Q: How to generate DynamoDB Access Key and Secret Key?
By Creating User from AWS IAM (Identity Access Management), will be able to generate access key
and secret key.
You can follow steps given from DynamoDB Setup to generate access key and secret key.
Q: What is DynamoDBMapper class?
The entry point for DynamoDB is the DynamoDBMapper class. It provides access to a DynamoDB endpoint and allows you to access your data from different tables, perform various CRUD operations, and execute queries and scans table.
Refer Spring Boot + DynamoDB Example to understand DynamoDBMapper.
Q: List methods of DynamoDBMapper class.
Below are the methods of DynamoDBMapper:
Saves the specified object to the table. The object that you want to save is the only required parameter for this method. You can provide optional configuration parameters using the DynamoDBMapperConfig object.
mapper.save(obj, new DynamoDBMapperConfig(DynamoDBMapperConfig.SaveBehavior.CLOBBER));
Retrieves an item from a table. You must provide the primary key of the item that you want to retrieve. You can provide optional configuration parameters using the DynamoDBMapperConfig object.
BookCatalog catalog = mapper.load(BookCatalog.class, catalog.getId(), new DynamoDBMapperConfig(DynamoDBMapperConfig.ConsistentReads.CONSISTENT));
Deletes an item from the table. You must pass in an object instance of the mapped class.
Queries a table or a secondary index. You can query a table or an index only if it has a composite primary key (partition key and sort key).
Scans an entire table or a secondary index. You can optionally specify a FilterExpression to filter the result set.
Scans a table or secondary index and returns a single page of matching results. As with the scan method, you can optionally specify a FilterExpression to filter the result set. However, scanPage only returns the first "page" of data, that is, the amount of data that fits within 1 MB.
Performs a parallel scan of an entire table or secondary index. You specify a number of logical segments for the table, along with a scan expression to filter the results.
Saves objects to one or more tables using one or more calls to the AmazonDynamoDB.batchWriteItem method. This method does not provide transaction guarantees.
Retrieves multiple items from one or more tables using their primary keys.
Deletes objects from one or more tables using one or more calls to the AmazonDynamoDB.batchWriteItem method. This method does not provide transaction guarantees.
Saves objects to and deletes objects from one or more tables using one or more calls to the AmazonDynamoDB.batchWriteItem method. This method does not provide transaction guarantees or support versioning (conditional puts or deletes).
Saves objects to and deletes objects from one or more tables using one call to the AmazonDynamoDB.transactWriteItems method.
Loads objects from one or more tables using one call to the AmazonDynamoDB.transactGetItems method.
Evaluates the specified scan expression and returns the count of matching items. No item data is returned.
Parses a POJO class that represents a DynamoDB table, and returns a CreateTableRequest for that table.
Creates a link to an object in Amazon S3. You must specify a bucket name and a key name, which uniquely identifies the object in the bucket.
Returns the underlying S3ClientCache for accessing Amazon S3. An S3ClientCache is a smart Map for AmazonS3Client objects. If you have multiple clients, an S3ClientCache can help you keep the clients organized by AWS Region, and can create new Amazon S3 clients on demand.
Q: Is DynamoDBMapper thread safe?
This class is thread-safe and can be shared between threads. While using the save, load, and delete methods, DynamoDBMapper will throw DynamoDBMappingException to show that domain classes are incorrectly annotated or otherwise incompatible with this class.
Q: Does Amazon DynamoDB support both increment and decrement atomic operations?
Yes,Amazon DynamoDB supports increment and decrement atomic operations.
Q: Does DynamoDB support in place atomic updates?
Amazon DynamoDB supports fast in-place updates. You can increment or decrement a numeric attribute in a row using a single API call. Similarly, you can atomically add or remove to sets, lists, or maps.
Q: Are DynamoDB writes Atomic?
DynamoDB allows atomic counters, in which it uses the update method to increment or decrement the value of an existing attribute without interfering with other write requests. Each time it runs the program, it increments this attribute by one.
Q: What kind of query functionality does DynamoDB support?
It supports the operation of GET/PUT using the primary key specified by the user. Flexible querying is enabled by allowing a non-primary key attribute to be queried using local secondary indexes and global secondary indexes.
Q: What is difference between MongoDB and DynamoDB?
MongoDB is designed and developed by MongoDB Inc.
DynamoDB is designed and developed by Amazon.com.
MongoDB uses JSON-like documents.
DynamoDB uses tables, items and attributes.
MongoDB is difficult to configure and install it. That is because it does not have provide guidance to perform. In order to make it easier to use MongoDB, they have provided MongoDB Atlas which is a cloud hosted.
Setting up and installation of DynamoDB is very easy since it is a web service provided by Amazon.com.
MongoDB supports more data types and has fewer size restrictions.
DynamoDB supports limited data types and smaller item sizes.
MongoDB is not so secure, because by default it keeps authentication off while installing MongoDB.
DynamoDB security is better and is usually supported by the security measure provided by AWS.
Q: Is Redis faster than DynamoDB?
Since DynamoDB is NoSQL, so Insert/Delete is so fast.(slower than Redis, but we don't need to that much speed) DynamoDB store data permanently.