Implement Relation query API.