javascript - 您将如何在 DynamoDB 中为一对多和多对多建模
问题描述
您将如何建模以下实体,并在 Node.js 中查询它们?
User --> has many Posts
Post --> each Post belongs to a single User
Image --> each Image belongs to either a User or a Post or an Organization
Organization --> each Organization has many Users,
--> each User can belong to many Organizations
您是否会在单独的表中创建每个实体并有一个指向所有者实体的字段(a la FK)?您是否会将它们全部存储在一个包含嵌套 json 字段的大型组织表中,并且非规范化数据在不同文档中重复多次?如果是这样 - 您将如何更新属于多个组织的用户字段?
解决方案
Relational data modeling is very different in NoSQL, compared to SQL (RDBMS), databases. There are a lot a great articles and videos on relational data modeling in DynamoDB. This article is a relatively simple example that you can use to help you get started.
As for the NodeJs part, it's just using the SDK to run the queries as outlined in the article. You'll primarily use the getItem
and query
functions.
推荐阅读
- html - 引导导航栏切换器
- python - Flask:谷歌云功能和谷歌网络部署的区别
- .net-core - 在 azure devops 版本上安装并运行自定义 dotnet 工具
- reactjs - Onchange 字段数据正在成为 [object object] 反应
- javascript - React-Apollo:在上下文中找不到“客户端”或作为选项传入
- android - 有没有办法可视化使用 Android Studio 开发的 Flutter 应用程序中的特定 UI 元素?
- git - gitpython 获取带有分离头的最后一次提交
- r - R中的映射:无法将文本框移出我的地图
- r - R如何滞后4000列50次
- excel - 如何将范围从一个工作表剪切到粘贴到第二个并确保将来的行转到下一个空白行?