SimpleDB 对属性名称的查询
我不知道 simpledb 是否可以这样做。我正在尝试使用 以下类型的 simpledb 数据结构。
每个项目都有多个名称/值对(这里的名称是属性名称) 例如
项目1
序列号->值
项目2
序列号-> value一个域中存在这样数量的项目,并且存在多个这样的域。
我想查询类似的内容:
select * from domain where attribute-name = 'serial number'
获取与跨多个项目和域的一个序列号相关的所有项目; 这可能吗?
我的第二个问题是关于使用字段组合作为项目名称。
例如
在上面提到的结构中,
Foo_datetime
serial -> value
Foo1_datetime
serial -> value
然后我会查询特定日期时间范围之间的项目以及特定的 Foo 或 Foo1? 类似的东西
select * from domain where itemname = 'Foo' and itemname > datetime and itemname < datetime.
I don't know something like this is possible or not with simpledb. I am trying to use
following type of simpledb data structure.
Each item has multiple name/value pairs (name here is attribute-name)
e.g.item1
serial_num -> value
item2
serial_num -> valuesuch number of items are there in a domain and there are multiple such domains.
I want to query something like:
select * from domain where attribute-name = 'serial number'
to get all the items related to one serial number across multiple items and domains;
is this possible?
My second question is regarding using combination of fields as item names.
e.g
in above mentioned structure,
Foo_datetime
serial -> value
Foo1_datetime
serial -> value
And I would then query items between certain datetime range and for perticular Foo or Foo1?
something like
select * from domain where itemname = 'Foo' and itemname > datetime and itemname < datetime.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于您的第一个问题,您建议的查询将按照您的预期工作,无论您“选择 *”还是“选择serial_num”,它都会以任何方式工作。 SimpleDB 查询语言类似于 SQL。但是,无法将单个查询应用于多个域。每个查询都特定于单个域。要发出跨域查询,您必须向每个域发出查询。这会成倍增加您的查询量,但是查询可以一次性发送,无需等待,因此不会增加您等待响应的时间。
要回答第二个问题,项目名称确实可以用于存储数据并查询数据。在这种情况下,您需要在查询中使用函数“itemName()”。修复最终示例的重写如下所示:
其中日期时间 1 和 2 被替换为实际值。
For your first question, the query you suggest will work just as you expect, whether you "select *" or "select serial_num", it works either way. The SimpleDB query language is similar to SQL. There is no way to get a single query to apply to multiple domains though. Each query is specific to a single domain. To issue cross-domain queries you must issue a query to each domain. This multiplies your query volume however the queries can be sent all at once without waiting, so it does not multiply the time you wait for responses.
To answer the second question, the item names can indeed be used to store data and query it. In this case you need to use the function "itemName()" within your query. A rewrite to fix your final example looks like this:
Where datetime 1 and 2 are replaced with actual values.
只是想在 Mocky 的回答中添加一点:
SimpleDB 将日期存储/比较为字符串。因此要小心,避免像 2010-1-22 这样存储日期,并始终以符合 ISO 8601 的格式存储日期。
Just want to add a little bit to Mocky's answer:
SimpleDB stores/compares dates as strings. So be careful and avoid dates stored like 2010-1-22 and always store dates in an ISO 8601 compliant format.