在单表DynamoDB中共享对象
我对单台设计的设计是相对较新的,并且正在创建一个单台数据库,该数据库合并了成员之间的共享,我希望能够发送一个查询,该查询返回与用户关联的所有对象和对象详细信息强>。
这是我的意思是一个玩具示例:
假设有一个带有汽车详细信息的单桌子,同时将汽车详细信息与业主联系起来。 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:
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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要么发出第二个请求(这不是很昂贵,这是关系数据库在发出这样的加入时内部所做的),要么您将数据归政以保留在用户记录下存储的汽车数据的副本并维护数据同步自己,然后您可以快速获取。最好取决于您的延迟需求。
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.