Reputation: 9422
Here is an article about how to handle many-to-many relations in DynamoDB: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-adjacency-graphs.html
What this abstract schema for bills and invoices means:
It looks like that table can be created by using following command:
aws dynamodb create-table \
--table-name InvoicesAndBills \
--attribute-definitions \
AttributeName=PartitionKey,AttributeType=S \
AttributeName=SortKey,AttributeType=S \
--key-schema \
AttributeName=PartitionKey,KeyType=HASH \
AttributeName=SortKey,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST \
--global-secondary-indexes '[
{
"IndexName": "GSI",
"KeySchema": [
{"AttributeName": "SortKey", "KeyType": "HASH"}
],
"Projection": {
"ProjectionType": "ALL"
}
}
]'
But I don't understand how data should look like? What means Inv_ID
and Bill_ID
of sort key?
Is it should be like a joined string of IDs?
[
{
"PartitionKey": "Invoice-92551"
"SortKey": "Inv_ID=Invoice-92551#Bill_ID=Bill-4224663#Bill_ID=Bill-4224687#Bill_ID=..."
}
]
(Because here is another article explaining how to use sort keys with multiple values)
Or this schema means a set of objects?:
[
{
"PartitionKey": "Invoice-92551"
"SortKey": "Bill-4224663"
},
{
"PartitionKey": "Invoice-92551"
"SortKey": "Bill-4224687"
},
{
"PartitionKey": "Invoice-92551"
"SortKey": "..."
},
]
So the summarized questions are:
Upvotes: 1
Views: 18