Amazon dynamodb DynamoDB中的一对多模式

Amazon dynamodb DynamoDB中的一对多模式,amazon-dynamodb,Amazon Dynamodb,我目前正在为以下用例设计dynamo DB模式: 一个公司可以有很多渠道,然后对于每个渠道,我有多个渠道卡 我正在考虑以下表格: 频道表: Partition Key: CompanyId Sort Key: Combination of Time Stamp and deleted or not 现在,在获得一家公司的频道后,我需要获取它的频道卡,为此,我想为ChannelCard提供下表模式 信道卡表: Partition Key: channelId Sort Key: Combinat

我目前正在为以下用例设计dynamo DB模式:

一个公司可以有很多渠道,然后对于每个渠道,我有多个渠道卡

我正在考虑以下表格:

频道表:

Partition Key: CompanyId
Sort Key: Combination of Time Stamp and deleted or not
现在,在获得一家公司的频道后,我需要获取它的频道卡,为此,我想为ChannelCard提供下表模式

信道卡表:

Partition Key: channelId
Sort Key: Combination of Time Stamp and deleted or not
现在,要获得公司的渠道卡,我需要执行以下操作:

 1. First query the channels for the company using partition key (1 query)
 2. Getting channel cards for each channel (number of channels query)
因此,在这种情况下,我们将进行许多查询,在我们的情况下,是否可以减少查询的数量

欢迎对修改数据库表或如何查询数据库提出任何建议。

您也可以

通道表

Partition Key: CompanyId
Sort Key: Deleted+timestamp
通道卡表

Partition Key: CompanyId
Sort Key: Deleted+ChannelCardTimeStamp

GSI #1:
Partition Key: ChannelId
Sort Key: Deleted+ChannelCardTimeStamp
通过这种方式,您可以查询任何给定公司的最新channelcards,也可以查询任何频道的最新channelcards