3

我不知道使用 simpledb 是否可能发生这样的事情。我正在尝试使用以下类型的 simpledb 数据结构。

  1. 每个项目都有多个名称/值对(这里的名称是属性名称)例如

    item1序列号
    -> 值
    item2 序列号
    -> 值

  2. 这样数量的项目存在于一个域中,并且有多个这样的域。

我想查询类似:

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.
4

2 回答 2

4

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:

select * from domain where itemName() between 'Foodatetime1' and 'Foodatetime2'

Where datetime 1 and 2 are replaced with actual values.

于 2010-06-21T14:32:48.683 回答
1

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.

于 2012-02-22T11:13:58.377 回答