;
create view filerefs as
-select F.hash, count(PF.hash) + count(S.hash) + count(EL.file) as refcount
+select F.hash,
+count(PF.hash) + count(S.hash) + count(EL.file) + count(N.file) as refcount
from files F
left join packagefiles PF on PF.hash = F.hash
left join scripts S on S.hash = F.hash
left join elflibraries EL on EL.file = F.hash
+left join notes N on N.file = F.hash
group by F.hash
;