first of all make sure you are using Medusa V2 and not V1. then follow the docs to add the relationship using the link module.
to extend functionality make use of subscribers, overriding apis, hooks, etc
most are in the website docs