Based on what you have said, I think the need for a union query comes from here:
It strikes me that having a unique book database for each subject is not the optimal solution, and the need for the union query is a workaround for the inability to solve the real issue.
I think the real problem that needs solving is
You want to be able to select a book (from amongst thousands) based on the the context of the entity you are picking from, right?
This would seem to be related to this:
It is partly solved, by hierarchical relations, but this doesn’t work in your case, because that functionality is not supported for many-to-many relations.
At this point, I wonder if anyone in the community has any suggestions for how to help you (either with a better tool suggestion, or with a better Fibery data model).