use relation to resolve references

as discussed, this logic belongs to TableInfo.getReferenceInfo