Query builder with dependencies