Santiago Palladino

Santiago Palladino

SimpleDb SQL-Like Query Language

3 min
Dec 18 2008
amazon web services
3 min
Dec 18 2008

In my last post, I blogged about non-first normal form, SimpleDb in particular, and the problems that arose in the query language when dealing with multiple attributes, such as "a != b" not being the same as "not a = b".

The SimpleDb team has now released a comfortable SQL like query language to be used for selecting data, in addition to the old language.

What is most interesting about this language is how the multi-valued attributes issue is resolved, a problem that SQL (luckily) does not have to deal with.

Each attribute is considered individually against the comparison conditions defined in the predicate. Item names are selected if any of the values match the predicate condition. To change this behavior, use the every() operator to return results where every attribute matches the query expression.

The simple addition of the every keyword allows easy querying over multi valued attributes.

Therefore, the query select * from domain where stamp > '100' would return an item with two stamps valued 50 and 150. But select * from domain where every(stamp) > '100' would not return it.

It also allows for some interesting uses, such as select * from domain where every(tag) in ('work', 'sports'); which will return all items tagged only with work and sports, since every tag in the item must be contained in the set for the item to be returned.

In a few words, an excellent addition to the engine by the SimpleDb team. Some minor quirks are still present (it is still necessary to include an attribute in the where section in order to be able to sort by it), but overall it is a great piece of work.