Include logic for building a query from selected tables and columns.