Skip to Content

DVA-C02: Flexible NoSQL Data Modeling with Amazon DynamoDB

Learn how to leverage DynamoDB flexibility to model complex movie data with inconsistent attributes. Query movies by title, year, and genre.

Table of Contents

Question

A developer wants to store information about movies. Each movie has a title, release year, and genre. The movie information also can include additional properties about the cast and production crew. This additional information is inconsistent across movies. For example, one movie might have an assistant director, and another movie might have an animal trainer.

The developer needs to implement a solution to support the following use cases:

  • For a given title and release year, get all details about the movie that has that title and release year.
  • For a given title, get all details about all movies that have that title.
  • For a given genre, get all details about all movies in that genre.

Which data store configuration will meet these requirements?

A. Create an Amazon DynamoDB table. Configure the table with a primary key that consists of the title as the partition key and the release year as the sort key. Create a global secondary index that uses the genre as the partition key and the title as the sort key.

B. Create an Amazon DynamoDB table. Configure the table with a primary key that consists of the genre as the partition key and the release year as the sort key. Create a global secondary index that uses the title as the partition key.

C. On an Amazon RDS DB instance, create a table that contains columns for title, release year, and genre. Configure the title as the primary key.

D. On an Amazon RDS DB instance, create a table where the primary key is the title and all other data is encoded into JSON format as one additional column.

Answer

A. Create an Amazon DynamoDB table. Configure the table with a primary key that consists of the title as the partition key and the release year as the sort key. Create a global secondary index that uses the genre as the partition key and the title as the sort key.

Explanation

The correct answer is A. Create an Amazon DynamoDB table. Configure the table with a primary key that consists of the title as the partition key and the release year as the sort key. Create a global secondary index that uses the genre as the partition key and the title as the sort key.

The reason is that Amazon DynamoDB is a NoSQL database service that can store semi-structured data, such as JSON documents, and support flexible schema design. This makes it suitable for storing movie information that can have additional properties that are inconsistent across movies. Amazon DynamoDB also supports querying data by using primary keys and secondary indexes, which can help to implement the use cases.

The primary key of a DynamoDB table consists of a partition key and an optional sort key. The partition key determines how the data is distributed across partitions, and the sort key determines how the data is sorted within each partition. A global secondary index is an alternate view of the data in a DynamoDB table, with a different primary key. A global secondary index can span multiple partitions and support queries that cannot be supported by using the table’s primary key.

To support the use cases, the developer needs to create a DynamoDB table with a primary key that consists of the title as the partition key and the release year as the sort key. This will allow querying data by using both attributes, which can satisfy the first use case. For example, to get all details about the movie that has the title “The Matrix” and the release year 1999, the developer can use a query operation with the following parameters:

KeyConditionExpression: title = :title AND release_year = :release_year ExpressionAttributeValues: {“:title”: “The Matrix”, “:release_year”: 1999}

The developer also needs to create a global secondary index that uses the genre as the partition key and the title as the sort key. This will allow querying data by using both attributes, which can satisfy the second and third use cases. For example, to get all details about all movies that have the title “The Matrix”, regardless of their release year or genre, the developer can use a query operation on the global secondary index with the following parameters:

KeyConditionExpression: title = :title ExpressionAttributeValues: {“:title”: “The Matrix”}

To get all details about all movies in the genre “Action”, regardless of their title or release year, the developer can use a query operation on the global secondary index with the following parameters:

KeyConditionExpression: genre = :genre ExpressionAttributeValues: {“:genre”: “Action”}

Therefore, creating a DynamoDB table with a primary key that consists of the title as the partition key and the release year as the sort key, and creating a global secondary index that uses the genre as the partition key and the title as the sort key, will meet these requirements.

The other options are incorrect because they do not support all use cases or they are not cost-effective:

B. Creating a DynamoDB table with a primary key that consists of the genre as the partition key and the release year as the sort key, and creating a global secondary index that uses the title as the partition key, will not support all use cases. This configuration will allow querying data by using genre and release year, or by using title only, but it will not allow querying data by using title and release year together.

C. Creating an RDS DB instance and creating a table that contains columns for title, release year, and genre, with title as the primary key, will not support all use cases or store additional properties. This configuration will allow querying data by using title only, but it will not allow querying data by using release year or genre. Moreover, this configuration will not store any additional properties about the cast and production crew.

D. Creating an RDS DB instance and creating a table where the primary key is title and all other data is encoded into JSON format as one additional column, will not support all use cases or be cost-effective. This configuration will allow storing additional properties about the cast and production crew, but it will not allow querying data by using any attribute other than title. Moreover, this configuration will incur higher storage costs due to storing large JSON documents in one column.

The latest AWS Certified Developer – Associate DVA-C02 certification actual real practice exam question and answer (Q&A) dumps are available free, which are helpful for you to pass the AWS Certified Developer – Associate DVA-C02 exam and earn AWS Certified Developer – Associate DVA-C02 certification.

AWS Certified Developer - Associate DVA-C02 Exam Questions and Answers