Data structures and interfaces to execute database queries