issue #22244: refactor document associations

Not ready for pull yet

TODO: need a compound inverse in case of duplicate source key

resolves #1962.
This feature is going to get lost in the refactor. I'm not sure how we could possibly accommodate it.