的密鑰假設我有staff
表organization_id
如分區鍵和staff_id
作爲排序鍵的主鍵組成。另一方面,我有department
本地二級索引與department_id
爲排序鍵。讀不同的局部副索引一個DynamoDB表
{
...
KeySchema: [
{ AttributeName: "organization_id", KeyType: "HASH"},
{ AttributeName: "staff_id", KeyType: "RANGE" }
],
LocalSecondaryIndexes: [
{
IndexName: "department",
KeySchema: [
{ AttributeName: "organization_id", KeyType: "HASH"},
{ AttributeName: "department_id", KeyType: "RANGE" }
],
Projection: {
ProjectionType: "KEYS_ONLY"
}
}
],
AttributeDefinitions: [
{ AttributeName: "organization_id", AttributeType: "S" },
{ AttributeName: "staff_id", AttributeType: "S" },
{ AttributeName: "department_id", AttributeType: "S" }
]
...
}
正如人們可以很容易地弄清楚,有許多項目與不同staff_id
共享相同department
索引鍵。我需要查詢給定organization_id
的組織的部門列表。有沒有辦法從staff
表中檢索這個列表?我不想保留另一個departments
表。我是DynamoDB的新手,所以如果您對整體桌面設計有任何意見/建議,那麼非常歡迎。
我結束了維持'departments'表。 – kokeksibir