- Newest
- Most votes
- Most comments
DynamoDB tables are very confusing at first, coming from a relational database, thinking of it as JSON or even how you would lay out data in a spreadsheet.
Let's focus on the HR data, your second question.
First you would look up in the table with sork key=Warehouse_01
The data that would come back is
{ PK: "HR-974", SK: "Warehouse_01", "Attr1": "Murphy, John" }
Using that PK you could now make a second get item call where PK=HR-974 and get back all of that data (Employee information, Q1 order totals, Warehouse id, Job title history).
If you only wanted the employee data, you could look up for PK=HR-974 and SK=Employee_Name
It is not in the example... but there is probably an entry for the warehouse as well.
The PK=Warehouse_01 and there could be SK with any of the following: Location, Inventory type, Warehouse type, etc and the Data-Item attributes
What would the JSON look like is tricky to answer, because
- It depend on which slice of data through the table you grab
- Is it the JSON from DynamoDB or application specific JSON
In your application, you have to keep track of the fact that when SK is EmployeeName then Attr1 means EmployeeName, but if SK is <YYYY-QQ> then Attr1 means OrderTotals.
Raw JSON
{
PK: HR-974, SK: "Employee_Name", Attr1: "Murphy, John", ...
}
Application level JSON
{
EmployeeID: HR-974, Type: "Employee_Name", EmployeeName: "Murphy, John", ...
}
If this is helpful, subscribe to my https://thathelpfulhuman.com/serverless .
Relevant content
- Accepted Answerasked 10 months ago
- asked 2 years ago
- asked 3 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 4 months ago