如何最好地将此结构映射到亚马逊 SimpleDB
所以 simpledb 有一种电子表格数据模型。
我有一个应用程序只需要根据值存储键。只不过单个键可以有多个值。
将会有多个客户。每个客户端都有一个 id 和它自己的一组密钥。 如果可以的话,我想在现阶段坚持使用单个域。
我如何将其映射到 simpleDB 上?
我在想 域 = 我的域 项目=客户ID 属性.n.名称 = key_1 ... key_n attribute.n.value = val1 ... valn
这将满足为同一键存储多个值的能力。 但后来我发现我需要获取选择或知道示例中的所有属性 我有多少属性。我不会预先知道这一点。 我还允许从键(或属性)中删除特定值。我必须先寻找它。似乎在 select 中没有 attributeName() 函数,只有 itemName() 函数。
将项目名称设为 id + key + _n 的组合可能会更好吗? 例如,如果 id 是“myid”并且键是“boots”,则项目名称将为 'myidboots_1'
然后每个项目有一个名为“keyval”的属性。
我可以做一个 选择“keyval”,其中 itemName 像“myidboots_%”?
与普通的sql数据库相比还是有点麻烦。
也许我应该尝试像逗号分隔列表一样对值进行编码? 但它可能更麻烦,而且我还读到有 1000 个字符的限制。
还有其他建议吗?
So simpledb has a kind of spreadsheet data model.
I have an app that simply needs to store keys against values. Except that a single key can have multiple values.
There will be multiple clients. Each client has an id with it's own set of keys.
I'd like to stick with a single domain if I can at this stage.
How can I map this onto simpleDB?
I was thinking
domain = mydomain
item = clientid
attribute.n.name = key_1 ... key_n
attribute.n.value = val1 ... valn
That would satisfy the ability to store multiple values for the same key.
But then I found that I need to either get ALL attributes in my select or know example
how many attributes I have. I will not know this up front.
Also I allow deleting a specific value from a key (or attribute). I will have to search for it first. It seems that in the select there is no attributeName() function, just the itemName() function.
Would it perhaps be better to make the item name a combination of id + key + _n ?
e.g. if the id is 'myid' and the key is 'boots' then the item name would be
'myidboots_1'
And then have a single attribute per item called say 'keyval'.
and I can do a
select 'keyval' where itemName like 'myidboots_%' ?
Still kindof cumbersome compared to a normal sql database.
Maybe I should try encoding the values like a comma separated list?
Except that it's probably more cumbersome and also I've read that there is a 1000 character limit.
Any other suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我完全理解你的问题,但我认为指出 SimpleDB 允许你执行经典 SQL 样式查询可能会有所帮助,例如:
这将返回结果记录的所有属性/值。
I'm not sure I totally follow your question, but I think it might be helpful to point out that SimpleDB lets you do classic SQL style queries like:
This will return all the attributes/values for the resulting records.