The realtionship is defined using three fields RefModule, RefNum, RefLine.
The RefModule field is in all the tables , thats how it determines which table to look for.
FYI :
The actual design of the tables are different. I just simplified the design to acheive the goal.
For example : the POLine table has fields like po_num, po_line, ref_module, ref_num, ref_line
The Job table has fields like job, suffix, ref_module, ref_num, ref_line.