Fixed SQL queries to use `file` table as intended