Org-roam assigns each file a unique id, which it plaaces in its database: org-roam.db
org-roam.db
When you click a link in an org roam file, the link is just an id; emacs queries the database for this id, and jumps to the relevant file.