在单表DynamoDB中共享对象

发布于 2025-02-10 17:40:29 字数 848 浏览 2 评论 0原文

我对单台设计的设计是相对较新的,并且正在创建一个单台数据库,该数据库合并了成员之间的共享,我希望能够发送一个查询,该查询返回与用户关联的所有对象和对象详细信息强>。

这是我的意思是一个玩具示例:

假设有一个带有汽车详细信息的单桌子,同时将汽车详细信息与业主联系起来。 PK汽车包含汽车,发动机,所有者,标题和车轮信息。这是表:

“在此处输入图像描述”

我要建模的访问模式是为用户返回所有汽车和汽车详细信息在这种情况下,在这种情况下为用户#9128。使用PK/SK倒数的全局次级索引(GSI-1PK = SK,GSI-1SK = PK),我可以获取与它们关联的用户信息(2),但我显然没有得到汽车详细信息,例如引擎,车轮和标题详细信息。我可以为每辆车发送后续查询,但这似乎很昂贵,因此理想情况下,我会在一次通话中获取数据。

有其他方法可以构建数据,以便可以在维持在汽车中添加多个用户的能力的同时获得与用户关联的所有汽车详细信息?

谢谢!

I am relatively new to the single-table design and I am creating a single-table database that incorporates sharing amongst members and I want to be able to send one query that returns all objects and object details associated with a user.

Here is a toy example of what I mean:

Let's say there is a single-table with car details while relating car details with owners. The PK car contains car, engine, owner, title, and wheels info. Here is the table:

enter image description here

The access pattern I am trying to model is returning all of the cars AND CAR DETAILS for a user, in this case user#9128. With a global secondary index of the inverse of PK/SK (GSI-1PK = SK, GSI-1SK = PK) I can get the user information and the cars associated with them (2), but I obviously don't get the car details such as the engine, wheels, and title details. I can send follow-up queries for each car but that seems costly, so ideally I would get the data in one call.

enter image description here

Is there another way I can structure the data so that I can get all of the car details associated with a user while maintaining the ability to add multiple users to the car?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恰似旧人归 2025-02-17 17:40:30

您要么发出第二个请求(这不是很昂贵,这是关系数据库在发出这样的加入时内部所做的),要么您将数据归政以保留在用户记录下存储的汽车数据的副本并维护数据同步自己,然后您可以快速获取。最好取决于您的延迟需求。

You either issue the second request (which isn’t that costly, it’s what a relational database would do internally when issuing a join like this) or you denormalize the data to keep a copy of the car data stored under a user record and maintain the data sync yourself, then you can do a quick fetch. Which is best depends on your latency needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文