Filter through relations prevents duplicate table in query