aws dynamodb 中的引用完整性管理
Referential Integrity management in aws dynamodb
我正在尝试在我的 aws dynamodb 中保存类别数据 table。
Id | category | difficultyLevels
1 | History | ['Easy', 'Medium']
现在的问题是字符串 'Easy' 和 'Medium' 是硬编码的,明天如果我想将字符串 'Easy' 更改为 'easy'。那将是非常痛苦的。所以我正在考虑按如下方式实现我的 tables:-
Table - 难度级别
id | Difficulty_Level
1 | Easy
2 | Medium
Table - 类别
Id | category | difficultyLevels
1 | History | [1, 2]
此处类别 table 保存的是难度级别 ID 而不是实际值。
我是 NoSQL 世界的新手。那你能告诉我我的方法是否正确吗?还是有其他更好的选择
我什至看到这种方法的问题是,即使难度级别 'Easy' 从难度级别 table 中删除。它的引用出现在类别 table 中。这是我们可以在 RDBMS 中控制的东西。
像 Mongo 这样的 NoSQL 数据库没有引用完整性。
要实现上述要求,您可以在文档之间使用引用,其中 DifficultyLevel 集合的文档引用将在类别集合中使用。
请查看 Mongo 文档了解更多详情-https://docs.mongodb.com/manual/tutorial/model-referenced-one-to-many-relationships-between-documents/index.html
我正在尝试在我的 aws dynamodb 中保存类别数据 table。
Id | category | difficultyLevels
1 | History | ['Easy', 'Medium']
现在的问题是字符串 'Easy' 和 'Medium' 是硬编码的,明天如果我想将字符串 'Easy' 更改为 'easy'。那将是非常痛苦的。所以我正在考虑按如下方式实现我的 tables:-
Table - 难度级别
id | Difficulty_Level
1 | Easy
2 | Medium
Table - 类别
Id | category | difficultyLevels
1 | History | [1, 2]
此处类别 table 保存的是难度级别 ID 而不是实际值。 我是 NoSQL 世界的新手。那你能告诉我我的方法是否正确吗?还是有其他更好的选择
我什至看到这种方法的问题是,即使难度级别 'Easy' 从难度级别 table 中删除。它的引用出现在类别 table 中。这是我们可以在 RDBMS 中控制的东西。
像 Mongo 这样的 NoSQL 数据库没有引用完整性。 要实现上述要求,您可以在文档之间使用引用,其中 DifficultyLevel 集合的文档引用将在类别集合中使用。 请查看 Mongo 文档了解更多详情-https://docs.mongodb.com/manual/tutorial/model-referenced-one-to-many-relationships-between-documents/index.html