AWS Certified Database - Specialty: Exam DBS-C01 Practice Question

Database Schema Attributes: Understanding the Code Review | AWS Certified Database Specialty

Question

A database specialist is doing a code review of code implemented by a team developer.

A sample of the code is given below: aws dynamodb create-table \ --table-name Donations \ --attribute-definitions \ AttributeName=Organization,AttributeType=S \ AttributeName=User,AttributeType=S \ --key-schema \ AttributeName=Organization,KeyType=HASH \ AttributeName=User,KeyType=RANGE \ --provisioned-throughput \ ReadCapacityUnits=10,WriteCapacityUnits=5 Which statement is true about the schema attributes?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer: D.

In a DynamoDB table, a composite primary key consists of the partition key and the sort key.

The partition key is also called the hash attribute (since an internal hash function determines the physical storage partition where the item will be stored)

Sort key is also called the range attribute since items in the same partition are stored locally together in sorted order based on this key value.

In this scenario, Organization attribute is the partition key, and the User attribute is the sort key.

Therefore, Option D is CORRECT and other options are incorrect.

Reference:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/getting-started-step-1.html

The given code is using AWS CLI command to create a DynamoDB table with the name "Donations". The code is defining the attributes of the table using the attribute-definitions parameter and the key schema using the key-schema parameter. The code is also specifying the provisioned throughput capacity for the table using the provisioned-throughput parameter.

In the key schema parameter, the AttributeName "Organization" is defined as the HASH key type, and the AttributeName "User" is defined as the RANGE key type. This means that the combination of the "Organization" and "User" attributes is used to uniquely identify each item in the table.

The correct answer is option C, where the Organization attribute is the primary key and the User attribute is the sort key. In DynamoDB, the primary key is composed of a partition key and an optional sort key. The partition key is used to partition the data across multiple physical storage partitions, while the sort key is used to sort the items within a partition.

Therefore, in the given code, the "Organization" attribute is used as the partition key, and the "User" attribute is used as the sort key. This means that the data in the table will be partitioned based on the value of the "Organization" attribute, and within each partition, the items will be sorted based on the value of the "User" attribute.