How to establish relation between two contentTypes based on Specific Field?

I have create two content Types. One is for teacher role and other is for student role (Both roles are added). I want to to establish many to many reation between students and teachers. How can I approach this. If I add relation in teacher content type, it becomes the relation based on id of teacher and student content type but I want to the relation based on username.

Can anyone guide me in the right direction?

Look how it’s done here AmeriLingua - fantastic site with ESL edtech solutions.