issue #22244: refactor document associations

Not ready for pull yet

TODO: need a compound inverse in case of duplicate source key

resolves #1962.
This is the thing that swaps out a primary key for its model. This really should all be done in the model layer, ideally by `fetchRelated`. I didn't want to boil the ocean, though, on this refactor.