Introduction
This model helps you store and find data quickly using keys. It is easy to save whole documents like JSON without strict tables.
Jump into concepts and practice - no test required
This model helps you store and find data quickly using keys. It is easy to save whole documents like JSON without strict tables.
PutItem
{
"TableName": "TableName",
"Item": {
"PrimaryKey": { "S": "key_value" },
"Attribute1": { "S": "value1" },
"Attribute2": { "N": "123" }
}
}
GetItem
{
"TableName": "TableName",
"Key": {
"PrimaryKey": { "S": "key_value" }
}
}PutItem
{
"TableName": "Users",
"Item": {
"UserID": { "S": "user123" },
"Name": { "S": "Alice" },
"Age": { "N": "30" }
}
}GetItem
{
"TableName": "Users",
"Key": {
"UserID": { "S": "user123" }
}
}PutItem
{
"TableName": "Products",
"Item": {
"ProductID": { "S": "p001" },
"Details": { "M": {
"Name": { "S": "Laptop" },
"Price": { "N": "999" },
"Specs": { "M": {
"RAM": { "S": "16GB" },
"Storage": { "S": "512GB" }
}}
}}
}
}This example saves a book with its ISBN as key and then retrieves it.
PutItem
{
"TableName": "Books",
"Item": {
"ISBN": { "S": "978-1234567890" },
"Title": { "S": "Learn DynamoDB" },
"Author": { "S": "Jane Doe" },
"Details": { "M": {
"Pages": { "N": "250" },
"Publisher": { "S": "Tech Books" }
}}
}
}
GetItem
{
"TableName": "Books",
"Key": {
"ISBN": { "S": "978-1234567890" }
}
}Keys must be unique in the table to avoid overwriting data.
Document attributes can store nested data like JSON objects.
This model is great for flexible and fast lookups but not for complex joins.
Key-value and document store model uses unique keys to save and find data fast.
It allows storing flexible documents like JSON with nested details.
Ideal for simple, fast access to data without complex relationships.
Table.query(KeyConditionExpression='UserId = :uid', ExpressionAttributeValues={':uid': '789'}). What is the likely problem?