querying datalog db