问题描述
我有一个简单的关系模型,我想使用一个表设计在DyanamoDB中创建。该模型适用于餐厅评论应用:
实体是:
访问模式:
我正在努力3:与创建评论的用户displayName
查找餐馆的所有评论。
我可以将displayName
存储在评论项目中,但是如果我的用户更新了displayName
,则需要使用此displayName更新所有评论。
我正在为如何在单个查询中连接restaurant
review
和user
而苦苦挣扎。我得到的最接近的是:
Hash Key | Range Key | Data
----------------------------------------------------------------
user 1 | review1 | restaurant1
| review2 | restaurant3
| review23 | restaurant4
| profile | Kate Smith | [email protected]
user 2 | review5 | restaurant1
| review6 | restaurant2
| review7 | restaurant4
| profile | John Smith | [email protected]
restaurant1 | address#street#areaCode |
restaurant2 | address#street#areaCode |
我可以使用具有上述设计的GSI来满足模式1和2,但不能满足3。我还尝试过翻转设计,以便评论与餐厅相关,但仍然无法满足模式3。
我要在单个查询中使用单个表设计做些什么吗? 即使我可以在两个有效的查询中做到这一点。
非常感谢这里的任何建议!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)