开发者

SimpleDB query on attribute name

I don't know something like this is possible or not with simpledb. I am trying to use following type of simpledb data structure.

  1. Each item has mul开发者_如何学JAVAtiple name/value pairs (name here is attribute-name) e.g.

    item1

    serial_num -> value

    item2

    serial_num -> value

  2. such 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜