add relation query logic.