Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build a domain-specific query language?

Tags:

database

dsl

I have a biology database that I would like to query. There is also a given terminology bank I have access to that has formalizable predicates. I would like to build a query language for this DB using the predicates mentioned. How would you go about it? My solution is the following:

  1. formalize the predicates
  2. translate into a query language (sql, sparql, depends)
  3. Build a specific language with ANTLR or other such tools
  4. Translate from 3 to 2.

Is this a valid approach? Are there better ones? Any pointers would be much appreciated.

like image 430
Dervin Thunk Avatar asked Nov 17 '09 23:11

Dervin Thunk


People also ask

What is a domain specific language example?

One simple example for Domain Specific Language(DSL) is HTML which is used for the particular domain called web-based applications.

What is domain specific language?

A Domain-Specific Language (DSL) is a computer language that's targeted to a particular kind of problem, rather than a general purpose language that's aimed at any kind of software problem. Domain-specific languages have been talked about, and used for almost as long as computing has been done.


3 Answers

Take a look at Booleano.

like image 153
PaulMcG Avatar answered Oct 28 '22 11:10

PaulMcG


Use BNF to get a head-start into the language semantics..GoldParser will help you by playing around with the semantics and syntax (link here: http://www.devincook.com/). Once you have the BNF semantics sorted out, you can then build up actions based on the inputs, for example, a bnf grammar section dealing with extracting a composition of a limb's genetic makeup classification (I do not know if that is in existence, abstract example here but you get the gist) for a particular query...'fetch stats on limb where limb is leg', then behind the scenes you would issue a SQL select on a column alias or name from a predefined table ... I could be wrong on the approach... Hope it helps?

like image 36
t0mm13b Avatar answered Oct 28 '22 11:10

t0mm13b


I suggest you take a look at the i2b2 framework, it's a graphical query language and query engine platform for patient databases.

It's probably hard to grasp all first but do take a look at the CRC cell or webservice in there, you'll see how they approached SQL generation from a clinical graphical query language in an interesting way (albeit, not so performance friendly :))

like image 35
wsb3383 Avatar answered Oct 28 '22 13:10

wsb3383