Actually, it would be better if you could just do a single query here. At the moment you're doing a query for every relationship here.