but also to be able to do a query on any pair of tables separately
This is not what relational databases are meant to do. As a ridiculous example: relating someone's shoe size in table A to sunrise time for the timezone he lives in is not practical... You have to know ahead of time how things work, not take an a posteriori approach and say I want to connect any two tables at any time.
You are better off with a gigantic single table, and for each of the instances where :'but also to be able to do a query on any pair of tables separately' , do a full table scan. If you can link any two tables with just a few foreign keys, then many of those table should be merged.
And since you already made up your mind: Sure! Go for it, anything is possible, ignoring practicality.
Creqate a large key metadata table, that has some identifiers and rowid pairs from all tables that relate them as you want. This means any time you update any table you now have to update this larger metadata table for all tables. If you have 60 base tables, then every insert into a base requires a mass update to the metadata table. Combinatorics 101: that means how many pairs of rowids get added? 60 tables with say 200 rows each. Hint: lots! If you have lots of rows in base tables your metadata table will be the size of Kansas.
The other aspect of this approach is that if you ever have to reorg any of the base tables, the rowids are then invalid, so you have to rebuild the entire giant table.
Bottomline: either take the metadata choice or dump everything into one large table with lots of columns. For a very tiny dataset either one can be done. Some databases limit the number of columns a table can have. What db are you going to use? MySQL??