first version to convert nr-datalog to sql