issue #22244: refactor document associations

Not ready for pull yet

TODO: need a compound inverse in case of duplicate source key

resolves #1962.
The most awkward part of the implementation was that the raw FK in the xt.doc view was not easily transformable into a natural key, because it could be the FK for many different possible tables. So by consequence we're sending the database PK over the wire instead of the natural key. This is I think the only time in the application when this happens.

So now the browser has to resolve the autonumber ID into the appropriate model, and there was no way of doing that because there was no way to query by the primary key and not the natural key. So I had to make a way of doing that. The diff down in data.sql is relevant here.

Note that awkwardly, if you add a document association, that will be represented as an object with the natural key, whereas if you send back the document association as it had been sent to the browser (say you're deleting an association) then it's the primary key that gets sent over. There's some more trickery in data.sql that handles both use cases.