Updating the link api to properly use foreign keys