Implementation of logical query languages for databases