(task) Refactored Query Builder for better handling of One-to-Many relations