I would like to ask more in-depth this question:
in the intermediate table is it that the referencing rows MUST form a primary key, or can I create an "indipendent" primary key and just reference the rows without constraints to other tables? Actually I've already tried it and it seems to work, but I don't know if I'm missing anything. I need this to be able to leave one column "null" of three or four referenced tables. With my previous design postgres would retreive unwanted rows.
I hope I'm being clear enough.
No, there is no requirement that the foreign keys must form a composite primary key.
But you should enforce uniqueness on the pair, and a primary key is a simple method of achieving that. The other option is to create a unique non-clustered index or a constraint.
If it's not practically useful, then it's practically useless.