Help creating an automation for linking field

I have there tables that connect:

  1. Contact Log
  2. Students
  3. Contacts

What I want is an automation (or a script, but I am just learning Javascript so I am not there yet) that when I link a student into the contact log table it automatically looks up that student in the contacts table and links those contacts into the contact log table.