-- arguments: id:string; filename:string
SELECT file
FROM module_files as mf
LEFT JOIN files f on mf.fileid = f.fileid
WHERE mf.uuid = %(id)s AND mf.filename = %(filename)s;

-- arguments: id:string; filename:string
SELECT f.file
FROM module_files as mf
  LEFT JOIN files f on mf.fileid = f.fileid
  LEFT JOIN modules m on mf.module_ident = m.module_ident
WHERE m.uuid = %(id)s AND mf.filename = %(filename)s;

Join on the module to allow the uuid matching condition.
Join on the module to allow the uuid matching condition.
