如何确保我在 DynamoDB 中有 deleted/updated 我自己的记录,而 table 中没有用户 ID

How do I make sure that I have deleted/updated my own record in DynamoDB without USER ID in that table

我对 DynamoDB 很陌生。所以我对这个有很多疑问。

我做了如下模型关系

Table 关系

Tables 型号

用户Table

+-------------+------------+
| UserID (PK) | Attributes |
+-------------+------------+
|     U_01    |     ...    |
+-------------+------------+
|     U_02    |     ...    |
+-------------+------------+
|     U_03    |     ...    |
+-------------+------------+

项目Table

+-----------+------------+
| ProjectId | Attributes |
+-----------+------------+
|   PJ_01   |     ...    |
+-----------+------------+
|   PJ_02   |     ...    |
+-----------+------------+
|   PJ_03   |     ...    |
+-----------+------------+

用户项目Table

+-------------+----------------+------------+
| UserID (PK) | ProjectID (SK) | Attributes |
+-------------+----------------+------------+
|     U_01    |      PJ_01     |     ...    |
+-------------+----------------+------------+
|     U_02    |      PJ_02     |     ...    |
+-------------+----------------+------------+
|     U_03    |      PJ_01     |     ...    |
+-------------+----------------+------------+

套房 Table

+------------------+----------------+------------+
|   SuiteId (SK)   | ProjectId (PK) | Attributes |
+------------------+----------------+------------+
|  S_01            |      PJ_01     | ...        |
+------------------+----------------+------------+
|  S_02            |      PJ_02     | ...        |
+------------------+----------------+------------+
|  S_03            |      PJ_01     | ...        |
+------------------+----------------+------------+

个案Table

+-----------------+------------------+------------+
|   CaseId (PK)   |   SuiteId (SK)   | Attributes |
+-----------------+------------------+------------+
|       C_01      |        S_01      | ...        |
+-----------------+------------------+------------+
|       C_02      |        S_01      | ...        |
+-----------------+------------------+------------+
|       C_03      |        S_01      | ...        |
+-----------------+------------------+------------+

为了更新或删除测试用例(例如:C_01),我必须确保用户不得删除非拥有的项目(例如:U_02 不允许删除 C_01)。顺便说一句,我在通过身份验证后从令牌中获得了用户 ID

我设计了一个如下所示的 API 端点来更新或删除数据。你能告诉我你在这种情况下的最佳做法吗?非常感谢。

更新:/cases/:id

删除:/案例/:id

(我没有将 /projects/:prjId/suites/:sId/case/:cId 作为 API 创建中的 Microsoft 最佳实践建议)

几天后,我重新考虑了 table 处理关系模型的方式。

对于 DynamoDB,我们有 2 个定义来解析 RDS。 - 全球二级指数 (GSI) - Adjacency List

然后我找出 "AWS re:Invent 2018: Amazon DynamoDB Deep Dive: Advanced Design Patterns for DynamoDB" 视频。让我大吃一惊。

他们建议我们应该使用1 table for 1 applicationHierarchical Data Structure as Itemspair partition key and sort key to queryGSI

但直到@Rick Houlihan .

,我的情况仍然不清楚