0
0
DynamoDBquery~30 mins

Attribute types (S, N, B, BOOL, L, M) in DynamoDB - Mini Project: Build & Apply

Choose your learning style9 modes available
Working with DynamoDB Attribute Types
📖 Scenario: You are building a simple inventory system using DynamoDB. Each item in the inventory has different types of attributes like strings, numbers, booleans, lists, and maps.
🎯 Goal: Create a DynamoDB item using various attribute types: S (string), N (number), B (binary), BOOL (boolean), L (list), and M (map).
📋 What You'll Learn
Create a DynamoDB item dictionary named item with specific attributes.
Add a configuration variable binary_data to hold binary content.
Use the correct DynamoDB attribute types for each attribute in item.
Complete the item with all required attributes using the correct DynamoDB data types.
💡 Why This Matters
🌍 Real World
DynamoDB is widely used for fast, scalable NoSQL databases in web and mobile applications. Understanding attribute types is essential for storing and retrieving data correctly.
💼 Career
Many cloud and backend developer roles require working with DynamoDB or similar NoSQL databases. Knowing how to structure data with correct attribute types is a key skill.
Progress0 / 4 steps
1
Create the initial DynamoDB item with string and number attributes
Create a dictionary called item with two attributes: "ProductName" as a string with value "Coffee Mug" and "Price" as a number with value 12.99. Use DynamoDB attribute types S for string and N for number.
DynamoDB
Need a hint?

Remember, DynamoDB numbers are stored as strings inside the N attribute.

2
Add a binary attribute configuration
Create a variable called binary_data and assign it the byte string b'\x01\x02\x03' to represent binary data.
DynamoDB
Need a hint?

Use the b'' syntax to create a byte string in Python.

3
Add boolean, binary, list, and map attributes to the item
Add these attributes to the item dictionary: "InStock" as a boolean True using BOOL, "Image" as binary using B with the variable binary_data, "Tags" as a list L containing two strings "Ceramic" and "Kitchen", and "Dimensions" as a map M with keys "Height" and "Width" having number values 4 and 3 respectively.
DynamoDB
Need a hint?

Lists use L with a list of attribute dictionaries. Maps use M with a dictionary of attribute dictionaries.

4
Complete the DynamoDB item with all attributes
Ensure the item dictionary includes all attributes: ProductName (string), Price (number), InStock (boolean), Image (binary), Tags (list of strings), and Dimensions (map with height and width numbers). The variable binary_data should be defined as b'\x01\x02\x03'.
DynamoDB
Need a hint?

Review all attribute types and ensure the dictionary is complete and correctly formatted.