Implemented generating queries only for parent tables.