Linking fileIDs to filenames is done in stored procedures. If you look at the GetLink sproc, that is used for the links module (which can link to filenames), then you see this (abbreviated for readability):
select
[...]
'URL' = case when Files.FileName is null then Links.URL else Files.Folder + Files.FileName end,
[...]
from Links
[...]
left outer join Files on Links.URL = 'fileid=' + convert(varchar,Files.FileID)
where [...]
What is done here is that if the link points to a file (so a corresponding record exists in the files table), the URL is calculated from the values from the Files table, else the value from the Links table is used.
The other way around, if you want to find the fileID by fileName, you can use the core sproc GetFile, which looks like this:
CREATE procedure dbo.GetFile
@FileName nvarchar(100),
@PortalId int,
@Folder nvarchar(200)
as
select FileId,
FileName,
Extension,
Size,
WIdth,
Height,
ContentType
from Files
where FileName = @FileName AND Folder=@Folder
and ((PortalId = @PortalId) or (@PortalId is null and PortalId is null))
HTH
Cheers,
Erik