这是一个适当的用例亚马逊DynamoDB / NoSQL的? [英] Is this an appropriate use-case for Amazon DynamoDB / NoSQL?

查看:213
本文介绍了这是一个适当的用例亚马逊DynamoDB / NoSQL的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一堆亚马逊Web服务的Web应用程序。我想使用DynamoDB应用程序的特定部分,但我不知道这是否是一个适当的用例。

I'm working on a web application that uses a bunch of Amazon Web Services. I'd like to use DynamoDB for a particular part of the application but I'm not sure if it's an appropriate use-case.

在一个网站上的注册用户执行任务,一个条目被记录并保存该作业。作业具有一束与之相关联的细节,但最相关的是,每个作业都有一个唯一的标识符和相关联的用户名。用户名是唯一的过,但当然也可以有多个工作项为同一个用户,每个都有不同的作业的标识符

When a registered user on the site performs a "job", an entry is recorded and stored for that job. The job has a bunch of details associated with it, but the most relevant thing is that each job has a unique identifier and an associated username. Usernames are unique too, but there can of course be multiple job entries for the same user, each with different job identifiers.

的查询,我需要对这些数据进行的:给我所有的工作项(及其相关详细信息),输入用户名的 X

The only query that I need to perform on this data is: give me all the job entries (and their associated details) for username X.

我开始创建DynamoDB表,但我不知道这是否是正确的。我的理解是,所选择的哈希键应该是这是我们用来查询/索引到表中的关键,但它应该是每件/行唯一的。用户名是什么,我想通过查询,但用户名将不会每件/行唯一的。

I started to create a DynamoDB table but I'm not sure if it's right. My understanding is that the chosen hash key should be the key that's used for querying/indexing into the table, but it should be unique per item/row. Username is what I want to query by, but username will not be unique per item/row.

如果我做的作业标识符的主哈希键和用户名的辅助索引,将这项工作?我可以有一个辅助索引重复值?但是,这意味着我将永远不会使用的主哈希键查询/索引到表,这是它的全部意义,不是吗?

If I make the job identifier the primary hash key and the username a secondary index, will that work? Can I have duplicate values for a secondary index? But that means I will never use the primary hash key for querying/indexing into the table, which is the whole point of it, isn't it?

有什么我失踪,或者这只是没有非常适合的NoSQL。

Is there something I'm missing, or is this just not a good fit for NoSQL.

编辑:
该接受的答案帮我找到了我一直在寻找,以及<一个href="http://stackoverflow.com/questions/12484635/query-dynamodb-with-non-hash-key-field-with-boto-python">this问题。


The accepted answer helped me find out what I was looking for as well as this question.

推荐答案

我不是你问完全清楚,但我给它一个镜头...

I'm not totally clear on what you're asking, but I'll give it a shot...

通过DynamoDB,您的哈希键和范围键的组合必须唯一标识一个项目。范围关键是可选的;没有它,散列键必须独自唯一地标识一个项目。

With DynamoDB, the combination of your hash key and range key must uniquely identify an item. Range key is optional; without it, hash key alone must uniquely identify an item.

您还可以存储的值的列表(而不是只是一个单一的值)作为一个项目的属性。如果,例如,重$ P $每个项目psented一个用户,在该项目的属性可以是该用户的作业条目列表

You can also store a list of values (rather than just a single value) as an item's attributes. If, for example, each item represented a user, an attribute on that item could be a list of that user's job entries.

如果您担心击球DynamoDB记录的大小限制,您可以使用S3作为备份存储的清单 - 实际上使用DDB项存储的引用,包含给定用户的完整列表,S3资源。这使您可以灵活地查询或存储等属性相当容易。另外(如你在你的答案所建议的),你可以把整个用户记录在S3中,但你会失去一些做你查询的灵活性和吞吐量/通过DDB更新。

If you're concerned about hitting the size limitation of DynamoDB records, you can use S3 as backing storage for that list - essentially use the DDB item to store a reference to the S3 resource containing the complete list for a given user. This gives you flexibility to query for or store other attributes rather easily. Alternatively (as you suggested in your answer), you could put the entire user's record in S3, but you'd lose some of the flexibility and throughput of doing your querying/updating through DDB.

这篇关于这是一个适当的用例亚马逊DynamoDB / NoSQL的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆