dsl_erlang demo
Если вы помните, Torbjorn Tornkvist решил создать Natural Language DSL Engine, который позволил бы задаваь запросы к Mnesia на более-менее человеческом языке.
Появилась возможность проверить это на практике
Процес установки (с помощью следующий):
wget http://faxien.googlecode.com/files/faxien-launcher-universal-0.3.3.pysudo python faxien-launcher-universal-0.3.3.py
sudo /usr/local/erlware/bin/faxien install-release dsl_engine_demo
/usr/local/erlware/bin/dsl_engine_demo
После этого достаточно перейти в браузере по адресу http://localhost:9898/ и попробовать свои силы (или посмотреть на примеры).
В демо включены две таблицы:
invoice : table that contains all data related to a particular invoice
create_date : the date, in format: YYYY-MM-DD , when the invoice was created
goods_sum : an integer representing the sum of all goods
invno : holds the unique invoice number
inv_pno : the personal identification number, of the customer (e.g: 19630810-1234)
is_paid : a boolean; true if the invoice is paidperson : table that contains all data related to a particular customer
age : an integer, denoting a persons age
fname : a string containing a persons first name
lname : a string containing a persons last name
pno : a string containing the personal identification number (e.g: 19630810-1234)
Для эих двух табли можно создать, например, следющие запросы:
> for every invoice and person
> where inv_pno = pno and create_date > 2007-03-01 and create_date < 2008-04-01
> return invno, fname and lname as a table[{dsl_engine_demo_values:invno({proj,table},X1),X2#person.fname,X2#person.lname} ||
X1 <- mnesia:table(invoice),
X1#invoice.create_date > 63339926400,
X1#invoice.create_date < 63374227200,
X2 <- mnesia:table(person),X1#invoice.pno =:= X2#person.pno]> for every invoice
> where goods_sum > 0
> return is_paid as counted[dsl_engine_demo_values:is_paid({proj,counted},X1) ||
X1 <- mnesia:table(invoice),
dsl_engine_demo_values:goods_sum(exec,X1) > 0]