0% found this document useful (0 votes)
9 views5 pages

Lab4 Sample Solutions

solution
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Lab4 Sample Solutions

solution
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lab 4: DynamoDB

DSCI 551 – Spring 2024


Due: 11:59pm, April 10, 2024, Wednesday
Points: 10

Create a DynamoDB table of your choice (except for the book example shown in class), with the
following requirements:
a. The table must have a sort key
b. The table must contain at least one item
c. The item must have attributes of all the following types:
i. String
ii. Number
iii. String set/Number set
iv. List
v. Map

Tasks:

1. Explain why you selected the particular attributes as the partition key and sort key.
[+2] clearly explain the reasons for key selections
[-1] for each key (partition or sort) explanation missing
2. Insert at least one item into the table that meets all the type requirements mentioned
above. Show a screenshot of this item in the DynamoDB console and identify each data type
in the item.
[+3] all requirements met (screenshot of the item and data type identification)
[-3] missing screenshot of the item
[-2] the screenshot cannot clearly show each data type or there is no text explanation
(some students explain it in Q3, which is also fine)
[-0.5] for each missing data type
3. Show the `JSON view` of the above item and explain its format (e.g., how each attribute’s
data type is presented in JSON view)
a. The `JSON view` can be found in DynamoDB console: DynamoDB > Explore items >
Edit item > JSON view

[+3] all requirements met (json view and format explanation)


[-3] missing json view
[-2] no explanation of the format
4. Execute the scan and query methods on your table. Show a screenshot for each operation.
[+2] show screenshots for both scan and query methods
[-1] for each screenshot missing
Submission Instructions:

1. Submit one document (word document or PDF) containing all the required answers and
screenshots for each task
2. Clearly mark each task with its number.

Sample Solutions: I created a DynamoDB table called `students`

1. In DynamoDB, the partition key determines how data is distributed across the system, while the sort
key allows the data within each partition to be ordered and enables efficient range queries. I chose
`lastName` as the partition key because it groups individuals by family, which can be useful for queries
targeting specific surnames. I chose `firstName` as the sort key because it can make sorting and querying
within family groups much easier.

2.
Attributes and Data Types:

● String: ‘firstName’ and ‘lastName’


● Number: ‘age’ and ‘height_cm’
● String set: ‘hobbies’
● List: ‘phoneNumbers’ containing phone number entries
● Map: ‘address’, including street, city, state, postal code

3. JSON view:

In the DynamoDB JSON view, each key is an attribute name and the value is another object specifying the
type of the attribute and the actual data. Each attribute’s data type is represented as follows:
● String (S): lastName and firstName are strings, indicated by "S": "value". For example,
"lastName": {"S": "Simpson"} means lastName is a string with the value "Simpson".
● Number (N): age and height_cm are numbers, shown as "N": "value". For instance, "age": {"N":
"20"} means that age is a number with the value 20.
● String Set (SS): hobbies is a string set, represented by "SS": ["value1", "value2"], like "hobbies":
{"SS": ["cycling", "reading"]} indicating hobbies includes the strings "cycling" and "reading".
● List (L): phoneNumbers is a list, denoted by "L": [{...}, {...}], where each item in the list is a map of
phone number entries.
● Map (M): address is a map, shown as "M": { "key1": {"S": "value1"}, "key2": {"S": "value2"}}. For
example, "address": {"M": {"city": {"S": "Los Angeles"}}}, indicating address contains structured
data like city, postCode, state, and streetAddress.

4.
- Items in the table

- scan result
- query result

You might also like